forked from pool/python-pydantic
* Fix: Add max length check to `pydantic.validate_email` * Docs: Fix pip commands to install v1 * Fixes the `maxlen` property being dropped on `deque` validation. Happened only if the deque item has been typed. Changes the `_validate_sequence_like` func, #6581 by * Importing create_model in tools.py through relative path instead of absolute path - so that it doesn't import V2 code when copied over to V2 branch, #6361 by @SharathHuddar * Add Pydantic `Json` field support to settings management, * Fixed literal validator errors for unhashable values * Fixed bug with generics receiving forward refs * Update install method of FastAPI for internal tests in CI, #6117 by @Kludex * Use packaging, not pkg_resources for versions. - Skip some truculent tests. * Security fix: Fix date and datetime parsing so passing either 'infinity' * BaseSettings now uses the special env settings to define which * Change the precedence of aliases so child model aliases override * Add support for required Optional with name: Optional[AnyType] = Field(...) * alias precedence logic changed so aliases on a field always take OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pydantic?expand=0&rev=38
79 lines
2.8 KiB
Diff
79 lines
2.8 KiB
Diff
From 5fd4002c62d3538efc3ff51f92850f4c0bf4ffab Mon Sep 17 00:00:00 2001
|
|
From: Maxwell G <maxwell@gtmx.me>
|
|
Date: Sat, 12 Aug 2023 00:21:50 +0000
|
|
Subject: [PATCH] Fix Python 3.12 test failures
|
|
|
|
---
|
|
tests/test_abc.py | 15 ++++++++++++---
|
|
tests/test_generics.py | 6 ++++--
|
|
tests/test_types.py | 6 +++++-
|
|
3 files changed, 21 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/tests/test_abc.py b/tests/test_abc.py
|
|
index 8beed04..d7e8f3d 100644
|
|
--- a/tests/test_abc.py
|
|
+++ b/tests/test_abc.py
|
|
@@ -1,4 +1,5 @@
|
|
import abc
|
|
+import sys
|
|
|
|
import pytest
|
|
|
|
@@ -40,7 +41,15 @@ def test_model_subclassing_abstract_base_classes_without_implementation_raises_e
|
|
|
|
with pytest.raises(TypeError) as excinfo:
|
|
Model(some_field='some_value')
|
|
- assert str(excinfo.value) == (
|
|
- "Can't instantiate abstract class Model with abstract methods "
|
|
- "my_abstract_classmethod, my_abstract_method, my_abstract_property, my_abstract_staticmethod" # noqa: Q000
|
|
+ message = (
|
|
+ (
|
|
+ "Can't instantiate abstract class Model with abstract methods "
|
|
+ "my_abstract_classmethod, my_abstract_method, my_abstract_property, my_abstract_staticmethod" # noqa: Q000
|
|
+ )
|
|
+ if sys.version_info < (3, 12)
|
|
+ else (
|
|
+ "Can't instantiate abstract class Model without an implementation for abstract methods "
|
|
+ "'my_abstract_classmethod', 'my_abstract_method', 'my_abstract_property', 'my_abstract_staticmethod'" # noqa: Q000
|
|
+ )
|
|
)
|
|
+ assert str(excinfo.value) == message
|
|
diff --git a/tests/test_generics.py b/tests/test_generics.py
|
|
index 68f93d4..23e6263 100644
|
|
--- a/tests/test_generics.py
|
|
+++ b/tests/test_generics.py
|
|
@@ -579,9 +579,11 @@ def test_partial_specification_name():
|
|
b: BT
|
|
|
|
partial_model = Model[int, BT]
|
|
- assert partial_model.__name__ == 'Model[int, BT]'
|
|
+ expected = 'Model[int, BT]' if sys.version_info < (3, 12) else 'Model[int, TypeVar]'
|
|
+ assert partial_model.__name__ == expected
|
|
concrete_model = partial_model[str]
|
|
- assert concrete_model.__name__ == 'Model[int, BT][str]'
|
|
+ expected += '[str]'
|
|
+ assert concrete_model.__name__ == expected
|
|
|
|
|
|
def test_partial_specification_instantiation():
|
|
diff --git a/tests/test_types.py b/tests/test_types.py
|
|
index b908d46..4277398 100644
|
|
--- a/tests/test_types.py
|
|
+++ b/tests/test_types.py
|
|
@@ -2713,7 +2713,11 @@ def test_secretfield():
|
|
class Foobar(SecretField):
|
|
...
|
|
|
|
- message = "Can't instantiate abstract class Foobar with abstract methods? get_secret_value"
|
|
+ message = (
|
|
+ "Can't instantiate abstract class Foobar with abstract methods? get_secret_value"
|
|
+ if sys.version_info < (3, 12)
|
|
+ else "Can't instantiate abstract class Foobar without an implementation for abstract method 'get_secret_value'"
|
|
+ )
|
|
|
|
with pytest.raises(TypeError, match=message):
|
|
Foobar()
|
|
--
|
|
2.41.0
|
|
|