tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.39k stars 357 forks source link

Unittest failed after upgrade pydantic to v2.5 #1535

Closed waketzheng closed 6 months ago

waketzheng commented 6 months ago

Describe the bug After upgrade pydantic to v2.5, make test_sqlite raises some errors:

...
-            'tortoise__contrib__pydantic__creator__tests__testmodels__Team__leaf': {'additionalProperties': False,
-                                                                                    'description': 'Team '
? ---                                                                                 ^ ^^^^^  ^^    ^^  ^

+                                                                                 'name': {'title': 'Name',
?                                                                                  ^^^ ^^^^^  ^^^    ^  ^ +

-                                                                                                   'that '
-                                                                                                   'is '
-                                                                                                   'a '
-                                                                                                   'playing',
? ---------                                                                                           ^^^

+                                                                                          'type': 'string'}},
?                                                                                           ++ ^^^^^^^^    ++

+                                                                  'required': ['id',
+                                                                               'name'],
+                                                                  'title': 'Reporter',
+                                                                  'type': 'object'},
+            'pydantic__main__tests__testmodels__Team__leaf': {'additionalProperties': False,
...
=========================================================== short test summary info ===========================================================
FAILED tests/contrib/test_pydantic.py::TestPydantic::test_address_schema - AssertionError: {'$de[314 chars]defs/tortoise__contrib__pydantic__creator__tes[2684 chars]ect'} != {'$de[314 chars]defs/pydantic__main__te...
FAILED tests/contrib/test_pydantic.py::TestPydantic::test_event_schema - AssertionError: {'$defs': {'tortoise__contrib__pydantic__creator__tes[3197 chars]ect'} != {'$defs': {'pydantic__main__tests__testmodels__A...
FAILED tests/contrib/test_pydantic.py::TestPydantic::test_eventlist_schema - AssertionError: {'$de[313 chars]defs/tortoise__contrib__pydantic__creator__tes[3014 chars]ray'} != {'$de[313 chars]defs/pydantic__main__te...
FAILED tests/contrib/test_pydantic.py::TestPydantic::test_team_schema - AssertionError: {'$de[314 chars]defs/tortoise__contrib__pydantic__creator__tes[2745 chars]ect'} != {'$de[314 chars]defs/pydantic__main__te...
FAILED tests/contrib/test_pydantic.py::TestPydantic::test_tournament_schema - AssertionError: {'$de[312 chars]defs/tortoise__contrib__pydantic__creator__tes[2779 chars]ect'} != {'$de[312 chars]defs/pydantic__main__te...
5 failed, 1060 passed, 65 skipped, 4 xfailed in 58.17s
make: *** [Makefile:47: test_sqlite] Error 1

To Reproduce

git clone git@github.com:tortoise/tortoise-orm.git
cd tortoise-orm
poetry shell
make deps
pip install --upgrade pydantic
make test_sqlite

Expected behavior Tests pass.

Additional context It is cause by the diff of pydantic.main.create_model: https://github.com/pydantic/pydantic/compare/v2.4.2...v2.5.0#diff-8708af8d26c26644976866f974e0b810b0940ede43ff487e457057d5a1f07999R1356