From cb5bb552f7dd650c0cceb89c7a24db4476c5c7ee Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 22 Jun 2026 09:10:03 -0400 Subject: [PATCH] [python] fix uniqueItems validation tests Pydantic 2 removed conlist(unique_items=True). The migration in 04fa53b6 kept OpenAPI arrays as lists because sets would lose ordering and complicate JSON serialization, but left the old validation tests in the synchronous and lazy-import samples. Those tests do not require an exception, so they normally pass after making a Petstore request and fail only when that request produces an unrelated response validation error. Remove them from the Pydantic 2 samples. Pydantic 1 still enforces uniqueItems. Make its test require the expected validation error so a regression cannot silently pass. --- .../python-lazyImports/tests/test_api_validation.py | 6 ------ .../python-pydantic-v1/tests/test_api_validation.py | 6 +++--- .../client/petstore/python/tests/test_api_validation.py | 6 ------ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/samples/openapi3/client/petstore/python-lazyImports/tests/test_api_validation.py b/samples/openapi3/client/petstore/python-lazyImports/tests/test_api_validation.py index da1634eecebc..d0ffe5f70dbd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/tests/test_api_validation.py +++ b/samples/openapi3/client/petstore/python-lazyImports/tests/test_api_validation.py @@ -40,12 +40,6 @@ def setUpModels(self): self.pet.category = self.category self.pet.tags = [self.tag] - def test_set_param_validation(self): - try: - self.pet_api.find_pets_by_tags(["a", "a"]) - except ValidationError as e: - self.assertTrue("the list has duplicated items" in str(e)) - def test_required_param_validation(self): try: self.pet_api.get_pet_by_id() # type: ignore diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_validation.py b/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_validation.py index d4c89e23946d..81ffe035470c 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_validation.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/tests/test_api_validation.py @@ -47,10 +47,10 @@ def setUpModels(self): self.pet.tags = [self.tag] def test_set_param_validation(self): - try: + with self.assertRaisesRegex( + ValidationError, "the list has duplicated items" + ): self.pet_api.find_pets_by_tags(["a", "a"]) - except ValidationError as e: - self.assertTrue("the list has duplicated items" in str(e)) def test_required_param_validation(self): try: diff --git a/samples/openapi3/client/petstore/python/tests/test_api_validation.py b/samples/openapi3/client/petstore/python/tests/test_api_validation.py index da1634eecebc..d0ffe5f70dbd 100644 --- a/samples/openapi3/client/petstore/python/tests/test_api_validation.py +++ b/samples/openapi3/client/petstore/python/tests/test_api_validation.py @@ -40,12 +40,6 @@ def setUpModels(self): self.pet.category = self.category self.pet.tags = [self.tag] - def test_set_param_validation(self): - try: - self.pet_api.find_pets_by_tags(["a", "a"]) - except ValidationError as e: - self.assertTrue("the list has duplicated items" in str(e)) - def test_required_param_validation(self): try: self.pet_api.get_pet_by_id() # type: ignore