diff --git a/pydantic/generics.py b/pydantic/generics.py
--- a/pydantic/generics.py
+++ b/pydantic/generics.py
@@ -17,6 +17,7 @@
     Union,
     cast,
 )
+from weakref import WeakKeyDictionary, WeakValueDictionary
 
 from typing_extensions import Annotated
 
@@ -25,7 +26,7 @@
 from .main import BaseModel, create_model
 from .types import JsonWrapper
 from .typing import display_as_type, get_all_type_hints, get_args, get_origin, typing_base
-from .utils import LimitedDict, all_identical, lenient_issubclass
+from .utils import all_identical, lenient_issubclass
 
 if sys.version_info >= (3, 10):
     from typing import _UnionGenericAlias
@@ -33,15 +34,28 @@
 GenericModelT = TypeVar('GenericModelT', bound='GenericModel')
 TypeVarType = Any  # since mypy doesn't allow the use of TypeVar as a type
 
+CacheKey = Tuple[Type[Any], Any, Tuple[Any, ...]]
 Parametrization = Mapping[TypeVarType, Type[Any]]
 
-_generic_types_cache: LimitedDict[Tuple[Type[Any], Union[Any, Tuple[Any, ...]]], Type[BaseModel]] = LimitedDict()
+# weak dictionaries allow the dynamically created parametrized versions of generic models to get collected
+# once they are no longer referenced by the caller.
+if sys.version_info >= (3, 9):  # Typing for weak dictionaries available at 3.9
+    GenericTypesCache = WeakValueDictionary[CacheKey, Type[BaseModel]]
+    AssignedParameters = WeakKeyDictionary[Type[BaseModel], Parametrization]
+else:
+    GenericTypesCache = WeakValueDictionary
+    AssignedParameters = WeakKeyDictionary
+
+# _generic_types_cache is a Mapping from __class_getitem__ arguments to the parametrized version of generic models.
+# This ensures multiple calls of e.g. A[B] return always the same class.
+_generic_types_cache = GenericTypesCache()
+
 # _assigned_parameters is a Mapping from parametrized version of generic models to assigned types of parametrizations
 # as captured during construction of the class (not instances).
 # E.g., for generic model `Model[A, B]`, when parametrized model `Model[int, str]` is created,
 # `Model[int, str]`: {A: int, B: str}` will be stored in `_assigned_parameters`.
 # (This information is only otherwise available after creation from the class name string).
-_assigned_parameters: LimitedDict[Type[Any], Parametrization] = LimitedDict()
+_assigned_parameters = AssignedParameters()
 
 
 class GenericModel(BaseModel):
@@ -67,7 +81,7 @@ def __class_getitem__(cls: Type[GenericModelT], params: Union[Type[Any], Tuple[T
 
         """
 
-        def _cache_key(_params: Any) -> Tuple[Type[GenericModelT], Any, Tuple[Any, ...]]:
+        def _cache_key(_params: Any) -> CacheKey:
             args = get_args(_params)
             # python returns a list for Callables, which is not hashable
             if len(args) == 2 and isinstance(args[0], list):
diff --git a/pydantic/utils.py b/pydantic/utils.py
--- a/pydantic/utils.py
+++ b/pydantic/utils.py
@@ -17,7 +17,6 @@
     Iterator,
     List,
     Mapping,
-    MutableMapping,
     NoReturn,
     Optional,
     Set,
@@ -80,7 +79,6 @@
     'get_unique_discriminator_alias',
     'get_discriminator_alias_and_values',
     'DUNDER_ATTRIBUTES',
-    'LimitedDict',
 )
 
 ROOT_KEY = '__root__'
@@ -803,39 +801,3 @@ def _get_union_alias_and_all_values(
     # unzip: [('alias_a',('v1', 'v2)), ('alias_b', ('v3',))] => [('alias_a', 'alias_b'), (('v1', 'v2'), ('v3',))]
     all_aliases, all_values = zip(*zipped_aliases_values)
     return get_unique_discriminator_alias(all_aliases, discriminator_key), all_values
-
-
-KT = TypeVar('KT')
-VT = TypeVar('VT')
-if TYPE_CHECKING:
-    # Annoying inheriting from `MutableMapping` and `dict` breaks cython, hence this work around
-    class LimitedDict(dict, MutableMapping[KT, VT]):  # type: ignore[type-arg]
-        def __init__(self, size_limit: int = 1000):
-            ...
-
-else:
-
-    class LimitedDict(dict):
-        """
-        Limit the size/length of a dict used for caching to avoid unlimited increase in memory usage.
-
-        Since the dict is ordered, and we always remove elements from the beginning, this is effectively a FIFO cache.
-
-        Annoying inheriting from `MutableMapping` breaks cython.
-        """
-
-        def __init__(self, size_limit: int = 1000):
-            self.size_limit = size_limit
-            super().__init__()
-
-        def __setitem__(self, __key: Any, __value: Any) -> None:
-            super().__setitem__(__key, __value)
-            if len(self) > self.size_limit:
-                excess = len(self) - self.size_limit + self.size_limit // 10
-                to_remove = list(self.keys())[:excess]
-                for key in to_remove:
-                    del self[key]
-
-        def __class_getitem__(cls, *args: Any) -> Any:
-            # to avoid errors with 3.7
-            pass

I was not able to create a short example for reproducibility, but I managed to identify the changes that "broke" our testsuite: #4083

If I revert both changes to [pydantic/generics.py](https://github.com/samuelcolvin/pydantic/blob/master/pydantic/generics.py), the errors in our testsuite disappear.

That might explain, why it's not easy to create a simple snippet for reproducibility, right? One needs to manage to exceed the limit...
Sorry for slow reply, yes makes sense.

I don't want to change the limits, but we should fail in a more transparent way.
I also added some debug messages in `pydantic/generics.py` to better understand what's happening.

I noticed for my case, that the caches `_generic_types_cache` and `_assigned_parameters` grow with each unittest, when the FastAPI app is re-created (in a fixture explicitly via `create_model`). It looks to me, like the retrieval from these caches is broken for dynamic models and/or `TypeVar`s:

The testsuite fixture defines a limited number of distinct models (including static and dynamic ones,  in total **23**), but whenever the application is rebuilt for the next test case, the models get rebuilt and added to the cache as the keys do not match. To be exact, `_generic_types_cache` very quickly grows to the specific limit, whereas `_assigned_parameters` goes up only to about 600.

To the best of my knowledge, this _cache problem_ (maybe the reason for the leak mentioned in #3829?) was also true for v1.9.0, but for some reasonit did not cause a `KeyError`.

> I don't want to change the limits

Yes, if my understanding of the observed problem is correct, changing the limit makes no difference. 

> we should fail in a more transparent way.

Given the specific error I observed, I'm wondering if it would make more sense to allow a _margin of error_ when comparing two different `TypeVars` that have the same name?

But that would probably only count as a workaround.

Maybe I should raise an issue with the developers of fastapi_pagination to not use `TypeVar`s or raise an issue with the developers of Python so that the comparison of `TypeVar`s changes:
```
>>> import typing
>>> t = typing.TypeVar("T")
>>> s = typing.TypeVar("T")
>>> t == s
False
>>> t is s
False
```

diff --git a/tests/requirements-testing.txt b/tests/requirements-testing.txt
--- a/tests/requirements-testing.txt
+++ b/tests/requirements-testing.txt
@@ -3,9 +3,9 @@ hypothesis==6.54.4
 # pin importlib-metadata as upper versions need typing-extensions to work if on Python < 3.8
 importlib-metadata==3.1.0;python_version<"3.8"
 mypy==0.971
-pytest==7.1.2
-pytest-cov==3.0.0
-pytest-mock==3.8.2
-pytest-sugar==0.9.5
+pytest==7.2.1
+pytest-cov==4.0.0
+pytest-mock==3.10.0
+pytest-sugar==0.9.6
 # pin typing-extensions to minimum requirement - see #4885
 typing-extensions==4.2.0
diff --git a/tests/test_edge_cases.py b/tests/test_edge_cases.py
--- a/tests/test_edge_cases.py
+++ b/tests/test_edge_cases.py
@@ -1894,7 +1894,7 @@ def get_double_a(self) -> float:
     model = Model(a=10.2)
     assert model.a == 10.2
     assert model.b == 10
-    return model.get_double_a() == 20.2
+    assert model.get_double_a() == 20.2
 
 
 def test_resolve_annotations_module_missing(tmp_path):
diff --git a/tests/test_generics.py b/tests/test_generics.py
--- a/tests/test_generics.py
+++ b/tests/test_generics.py
@@ -1,3 +1,5 @@
+import gc
+import itertools
 import json
 import sys
 from enum import Enum
@@ -6,12 +8,14 @@
     Callable,
     ClassVar,
     Dict,
+    FrozenSet,
     Generic,
     Iterable,
     List,
     Mapping,
     Optional,
     Sequence,
+    Set,
     Tuple,
     Type,
     TypeVar,
@@ -21,8 +25,19 @@
 import pytest
 from typing_extensions import Annotated, Literal
 
-from pydantic import BaseModel, Field, Json, ValidationError, root_validator, validator
-from pydantic.generics import GenericModel, _generic_types_cache, iter_contained_typevars, replace_types
+from pydantic import BaseModel, Field, Json, ValidationError, create_model, root_validator, validator
+from pydantic.generics import (
+    GenericModel,
+    _assigned_parameters,
+    _generic_types_cache,
+    iter_contained_typevars,
+    replace_types,
+)
+
+
+@pytest.fixture(autouse=True)
+def clean_cache():
+    gc.collect()  # cleans up _generic_types_cache for checking item counts in the cache
 
 
 def test_generic_name():
@@ -229,10 +244,13 @@ def test_cover_cache():
     class Model(GenericModel, Generic[T]):
         x: T
 
-    Model[int]  # adds both with-tuple and without-tuple version to cache
+    models = []  # keep references to models to get cache size
+
+    models.append(Model[int])  # adds both with-tuple and without-tuple version to cache
     assert len(_generic_types_cache) == cache_size + 2
-    Model[int]  # uses the cache
+    models.append(Model[int])  # uses the cache
     assert len(_generic_types_cache) == cache_size + 2
+    del models
 
 
 def test_cache_keys_are_hashable():
@@ -246,19 +264,66 @@ class MyGenericModel(GenericModel, Generic[T]):
     # Callable's first params get converted to a list, which is not hashable.
     # Make sure we can handle that special case
     Simple = MyGenericModel[Callable[[int], str]]
+    models = []  # keep references to models to get cache size
+    models.append(Simple)
     assert len(_generic_types_cache) == cache_size + 2
     # Nested Callables
-    MyGenericModel[Callable[[C], Iterable[str]]]
+    models.append(MyGenericModel[Callable[[C], Iterable[str]]])
     assert len(_generic_types_cache) == cache_size + 4
-    MyGenericModel[Callable[[Simple], Iterable[int]]]
+    models.append(MyGenericModel[Callable[[Simple], Iterable[int]]])
     assert len(_generic_types_cache) == cache_size + 6
-    MyGenericModel[Callable[[MyGenericModel[C]], Iterable[int]]]
+    models.append(MyGenericModel[Callable[[MyGenericModel[C]], Iterable[int]]])
     assert len(_generic_types_cache) == cache_size + 10
 
     class Model(BaseModel):
         x: MyGenericModel[Callable[[C], Iterable[str]]] = Field(...)
 
+    models.append(Model)
     assert len(_generic_types_cache) == cache_size + 10
+    del models
+
+
+def test_caches_get_cleaned_up():
+    types_cache_size = len(_generic_types_cache)
+    params_cache_size = len(_assigned_parameters)
+    T = TypeVar('T')
+
+    class MyGenericModel(GenericModel, Generic[T]):
+        x: T
+
+    Model = MyGenericModel[int]
+    assert len(_generic_types_cache) == types_cache_size + 2
+    assert len(_assigned_parameters) == params_cache_size + 1
+    del Model
+    gc.collect()
+    assert len(_generic_types_cache) == types_cache_size
+    assert len(_assigned_parameters) == params_cache_size
+
+
+def test_generics_work_with_many_parametrized_base_models():
+    cache_size = len(_generic_types_cache)
+    params_size = len(_assigned_parameters)
+    count_create_models = 1000
+    T = TypeVar('T')
+    C = TypeVar('C')
+
+    class A(GenericModel, Generic[T, C]):
+        x: T
+        y: C
+
+    class B(A[int, C], GenericModel, Generic[C]):
+        pass
+
+    models = [create_model(f'M{i}') for i in range(count_create_models)]
+    generics = []
+    for m in models:
+        Working = B[m]
+        generics.append(Working)
+
+    assert len(_generic_types_cache) == cache_size + count_create_models * 5 + 1
+    assert len(_assigned_parameters) == params_size + count_create_models * 3 + 1
+    del models
+    del generics
 
 
 def test_generic_config():
@@ -1379,3 +1444,57 @@ class Payload(BaseModel):
         'properties': {'payload_field': {'title': 'Payload Field', 'type': 'string'}},
         'required': ['payload_field'],
     }
+
+
+def memray_limit_memory(limit):
+    if '--memray' in sys.argv:
+        return pytest.mark.limit_memory(limit)
+    else:
+        return pytest.mark.skip(reason='memray not enabled')
+
+
+@memray_limit_memory('100 MB')
+def test_generics_memory_use():
+    """See:
+    - https://github.com/pydantic/pydantic/issues/3829
+    - https://github.com/pydantic/pydantic/pull/4083
+    - https://github.com/pydantic/pydantic/pull/5052
+    """
+
+    T = TypeVar('T')
+    U = TypeVar('U')
+    V = TypeVar('V')
+
+    class MyModel(GenericModel, Generic[T, U, V]):
+        message: Json[T]
+        field: Dict[U, V]
+
+    class Outer(GenericModel, Generic[T]):
+        inner: T
+
+    types = [
+        int,
+        str,
+        float,
+        bool,
+        bytes,
+    ]
+
+    containers = [
+        List,
+        Tuple,
+        Set,
+        FrozenSet,
+    ]
+
+    all = [*types, *[container[tp] for container in containers for tp in types]]
+
+    total = list(itertools.product(all, all, all))
+
+    for t1, t2, t3 in total:
+
+        class Foo(MyModel[t1, t2, t3]):
+            pass
+
+        class _(Outer[Foo]):
+            pass
diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -27,7 +27,6 @@
 from pydantic.utils import (
     BUILTIN_COLLECTIONS,
     ClassAttribute,
-    LimitedDict,
     ValueItems,
     all_identical,
     deep_update,
@@ -549,43 +548,3 @@ def test_on_lower_camel_one_length():
 
 def test_on_lower_camel_many_length():
     assert to_lower_camel('i_like_turtles') == 'iLikeTurtles'
-
-
-def test_limited_dict():
-    d = LimitedDict(10)
-    d[1] = '1'
-    d[2] = '2'
-    assert list(d.items()) == [(1, '1'), (2, '2')]
-    for no in '34567890':
-        d[int(no)] = no
-    assert list(d.items()) == [
-        (1, '1'),
-        (2, '2'),
-        (3, '3'),
-        (4, '4'),
-        (5, '5'),
-        (6, '6'),
-        (7, '7'),
-        (8, '8'),
-        (9, '9'),
-        (0, '0'),
-    ]
-    d[11] = '11'
-
-    # reduce size to 9 after setting 11
-    assert len(d) == 9
-    assert list(d.items()) == [
-        (3, '3'),
-        (4, '4'),
-        (5, '5'),
-        (6, '6'),
-        (7, '7'),
-        (8, '8'),
-        (9, '9'),
-        (0, '0'),
-        (11, '11'),
-    ]
-    d[12] = '12'
-    assert len(d) == 10
-    d[13] = '13'
-    assert len(d) == 9

`KeyError` in GenericModel.__parameterized_bases__.build_base_model
# Bug

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
             pydantic version: 1.9.1
            pydantic compiled: True
                 install path: /home/andi/virtualenvs/aimaas/lib/python3.9/site-packages/pydantic
               python version: 3.9.12 (main, Apr 18 2022, 22:40:46)  [GCC 9.4.0]
                     platform: Linux-5.4.0-113-generic-x86_64-with-glibc2.31
     optional deps. installed: ['dotenv', 'typing-extensions']
```
I'm afraid reproduction of this _issue_ is a bit tricky as I was not able to reproduce it in a production scenario nor with a small code snippet. So far, I only noticed this in the test suite of this [project](https://github.com/SUSE/aimaas), which contains multiple sub-modules for tests; but only tests in two **can** fail, i.e. when the entire testsuite runs, they fail; if I explicitly only run tests from these modules, they pass. 

This behavior probably also indicates a problem within the testsuite, which I intend to look for, but the problem does not occur with version 1.9.0 of pydantic. So, I figured it's worth sharing.

In the project, we dynamically define API routes for FastAPI for dynamically generated models (i.e. model definitions are stored in DB), i.e. the models and routes get generated/updated at start-up or when something changes in the DB. The callback function used for this looks something like this:

```python
def route_get_entities(router: APIRouter, schema: Schema):
    # this is the callback
    factory = EntityModelFactory()
    filter_model = _filters_request_model(schema=schema)

    @router.get(
        f'/{schema.slug}',
        response_model=Page[factory(schema=schema, variant=ModelVariant.GET)],
        response_model_exclude_unset=True
    )
    def get_entities(
        filters: filter_model = Depends(),
        order_by: str = Query('name', description=''),
        ascending: bool = Query(True, description=''),
        db: Session = Depends(get_db),
        params: Params = Depends()
    ):
        # the actual API route
        ...
```
The exception raised in the testsuite looks like this:
```
_____________________________________ ERROR at setup of TestRouteGetEntityChanges.test_raise_on_change_doesnt_exist ______________________________________

dbsession = <sqlalchemy.orm.session.Session object at 0x7fca28575580>

    @pytest.fixture
    def client(dbsession):
>       app = create_app(session=dbsession)

backend/tests/conftest.py:338: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
backend/__init__.py:53: in create_app
    load_dynamic_routes(db=session, app=app)
backend/__init__.py:40: in load_dynamic_routes
    create_dynamic_router(schema=schema, app=app)
backend/dynamic_routes.py:341: in create_dynamic_router
    route_get_entities(router=router, schema=schema)
backend/dynamic_routes.py:124: in route_get_entities
    response_model=Page[factory(schema=schema, variant=ModelVariant.GET)],
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:98: in __class_getitem__
    __base__=(cls,) + tuple(cls.__parameterized_bases__(typevars_map)),
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:224: in __parameterized_bases__
    yield from build_base_model(base_model, typevars_map)
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:190: in build_base_model
    parameterized_base = base_model.__class_getitem__(base_parameters)
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:98: in __class_getitem__
    __base__=(cls,) + tuple(cls.__parameterized_bases__(typevars_map)),
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:224: in __parameterized_bases__
    yield from build_base_model(base_model, typevars_map)
../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:185: in build_base_model
    base_parameters = tuple([mapped_types[param] for param in base_model.__parameters__])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <tuple_iterator object at 0x7fca2344e370>

>   base_parameters = tuple([mapped_types[param] for param in base_model.__parameters__])
E   KeyError: ~T

../../virtualenvs/aimaas/lib/python3.9/site-packages/pydantic/generics.py:185: KeyError
```
I checked the contents of `mapped_types` and `base_model.__parameters__` in the line where the exception gets raised:
```
>>> mapped_types
{~T: <class 'pydantic.main.PersonGet'>}
>>> a = list(mapped_types.keys())[0]
>>> a
~T
>>> b = base_model.__parameters__
>>> b[0]
~T
>>> a is b[0]
False
>>> type(a)
<class 'typing.TypeVar'>
>>> type(b[0])
<class 'typing.TypeVar'>
```
It looks like the `TypeVar`s, which are expected to be identical, no longer are. :thinking: 

tests/test_generics.py::test_caches_get_cleaned_up tests/test_generics.py::test_generics_work_with_many_parametrized_base_models
tests/test_edge_cases.py::test_str_bytes tests/test_edge_cases.py::test_str_bytes_none tests/test_edge_cases.py::test_union_int_str tests/test_edge_cases.py::test_union_int_any tests/test_edge_cases.py::test_union_priority tests/test_edge_cases.py::test_typed_list tests/test_edge_cases.py::test_typed_set tests/test_edge_cases.py::test_dict_dict tests/test_edge_cases.py::test_none_list tests/test_edge_cases.py::test_typed_dict[value0-result0] tests/test_edge_cases.py::test_typed_dict[value1-result1] tests/test_edge_cases.py::test_typed_dict[value2-result2] tests/test_edge_cases.py::test_typed_dict_error[1-errors0] tests/test_edge_cases.py::test_typed_dict_error[value1-errors1] tests/test_edge_cases.py::test_typed_dict_error[value2-errors2] tests/test_edge_cases.py::test_dict_key_error tests/test_edge_cases.py::test_tuple tests/test_edge_cases.py::test_tuple_more tests/test_edge_cases.py::test_tuple_length_error tests/test_edge_cases.py::test_tuple_invalid tests/test_edge_cases.py::test_tuple_value_error tests/test_edge_cases.py::test_recursive_list tests/test_edge_cases.py::test_recursive_list_error tests/test_edge_cases.py::test_list_unions tests/test_edge_cases.py::test_recursive_lists tests/test_edge_cases.py::test_str_enum tests/test_edge_cases.py::test_any_dict tests/test_edge_cases.py::test_success_values_include tests/test_edge_cases.py::test_include_exclude_unset tests/test_edge_cases.py::test_include_exclude_defaults tests/test_edge_cases.py::test_skip_defaults_deprecated tests/test_edge_cases.py::test_advanced_exclude tests/test_edge_cases.py::test_advanced_exclude_by_alias tests/test_edge_cases.py::test_advanced_value_include tests/test_edge_cases.py::test_advanced_value_exclude_include tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude0-expected0] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude1-expected1] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude2-expected2] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude3-expected3] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude4-expected4] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude5-expected5] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude6-expected6] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude7-expected7] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude8-expected8] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude9-expected9] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude10-expected10] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude11-expected11] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude12-expected12] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude13-expected13] tests/test_edge_cases.py::test_advanced_exclude_nested_lists[exclude14-expected14] tests/test_edge_cases.py::test_advanced_include_nested_lists[include0-expected0] tests/test_edge_cases.py::test_advanced_include_nested_lists[include1-expected1] tests/test_edge_cases.py::test_advanced_include_nested_lists[include2-expected2] tests/test_edge_cases.py::test_advanced_include_nested_lists[include3-expected3] tests/test_edge_cases.py::test_advanced_include_nested_lists[include4-expected4] tests/test_edge_cases.py::test_advanced_include_nested_lists[include5-expected5] tests/test_edge_cases.py::test_advanced_include_nested_lists[include6-expected6] tests/test_edge_cases.py::test_advanced_include_nested_lists[include7-expected7] tests/test_edge_cases.py::test_advanced_include_nested_lists[include8-expected8] tests/test_edge_cases.py::test_advanced_include_nested_lists[include9-expected9] tests/test_edge_cases.py::test_advanced_include_nested_lists[include10-expected10] tests/test_edge_cases.py::test_advanced_include_nested_lists[include11-expected11] tests/test_edge_cases.py::test_advanced_include_nested_lists[include12-expected12] tests/test_edge_cases.py::test_advanced_include_nested_lists[include13-expected13] tests/test_edge_cases.py::test_advanced_include_nested_lists[include14-expected14] tests/test_edge_cases.py::test_field_set_ignore_extra tests/test_edge_cases.py::test_field_set_allow_extra tests/test_edge_cases.py::test_field_set_field_name tests/test_edge_cases.py::test_values_order tests/test_edge_cases.py::test_inheritance tests/test_edge_cases.py::test_inheritance_subclass_default tests/test_edge_cases.py::test_invalid_type tests/test_edge_cases.py::test_valid_string_types[a tests/test_edge_cases.py::test_valid_string_types[some tests/test_edge_cases.py::test_valid_string_types[value2-foobar] tests/test_edge_cases.py::test_valid_string_types[123-123] tests/test_edge_cases.py::test_valid_string_types[123.45-123.45] tests/test_edge_cases.py::test_valid_string_types[value5-12.45] tests/test_edge_cases.py::test_valid_string_types[True-True] tests/test_edge_cases.py::test_valid_string_types[False-False] tests/test_edge_cases.py::test_valid_string_types[a10-a10] tests/test_edge_cases.py::test_valid_string_types[whatever-whatever] tests/test_edge_cases.py::test_invalid_string_types[value0-errors0] tests/test_edge_cases.py::test_invalid_string_types[value1-errors1] tests/test_edge_cases.py::test_inheritance_config tests/test_edge_cases.py::test_partial_inheritance_config tests/test_edge_cases.py::test_annotation_inheritance tests/test_edge_cases.py::test_string_none tests/test_edge_cases.py::test_return_errors_ok tests/test_edge_cases.py::test_return_errors_error tests/test_edge_cases.py::test_optional_required tests/test_edge_cases.py::test_invalid_validator tests/test_edge_cases.py::test_unable_to_infer tests/test_edge_cases.py::test_multiple_errors tests/test_edge_cases.py::test_validate_all tests/test_edge_cases.py::test_force_extra tests/test_edge_cases.py::test_illegal_extra_value tests/test_edge_cases.py::test_multiple_inheritance_config tests/test_edge_cases.py::test_submodel_different_type tests/test_edge_cases.py::test_self tests/test_edge_cases.py::test_self_recursive[BaseModel] tests/test_edge_cases.py::test_self_recursive[BaseSettings] tests/test_edge_cases.py::test_nested_init[BaseModel] tests/test_edge_cases.py::test_nested_init[BaseSettings] tests/test_edge_cases.py::test_init_inspection tests/test_edge_cases.py::test_type_on_annotation tests/test_edge_cases.py::test_assign_type tests/test_edge_cases.py::test_optional_subfields tests/test_edge_cases.py::test_not_optional_subfields tests/test_edge_cases.py::test_optional_field_constraints tests/test_edge_cases.py::test_field_str_shape tests/test_edge_cases.py::test_field_type_display[int-int] tests/test_edge_cases.py::test_field_type_display[type_1-Optional[int]] tests/test_edge_cases.py::test_field_type_display[type_2-Union[NoneType, tests/test_edge_cases.py::test_field_type_display[type_3-Union[int, tests/test_edge_cases.py::test_field_type_display[type_4-List[int]] tests/test_edge_cases.py::test_field_type_display[type_5-Tuple[int, tests/test_edge_cases.py::test_field_type_display[type_6-Union[List[int], tests/test_edge_cases.py::test_field_type_display[type_7-List[Tuple[int, tests/test_edge_cases.py::test_field_type_display[type_8-Mapping[int, tests/test_edge_cases.py::test_field_type_display[type_9-FrozenSet[int]] tests/test_edge_cases.py::test_field_type_display[type_10-Tuple[int, tests/test_edge_cases.py::test_field_type_display[type_11-Optional[List[int]]] tests/test_edge_cases.py::test_field_type_display[dict-dict] tests/test_edge_cases.py::test_field_type_display[type_13-DisplayGen[bool, tests/test_edge_cases.py::test_any_none tests/test_edge_cases.py::test_type_var_any tests/test_edge_cases.py::test_type_var_constraint tests/test_edge_cases.py::test_type_var_bound tests/test_edge_cases.py::test_dict_bare tests/test_edge_cases.py::test_list_bare tests/test_edge_cases.py::test_dict_any tests/test_edge_cases.py::test_modify_fields tests/test_edge_cases.py::test_exclude_none tests/test_edge_cases.py::test_exclude_none_recursive tests/test_edge_cases.py::test_exclude_none_with_extra tests/test_edge_cases.py::test_str_method_inheritance tests/test_edge_cases.py::test_repr_method_inheritance tests/test_edge_cases.py::test_optional_validator tests/test_edge_cases.py::test_required_optional tests/test_edge_cases.py::test_required_any tests/test_edge_cases.py::test_custom_generic_validators tests/test_edge_cases.py::test_custom_generic_arbitrary_allowed tests/test_edge_cases.py::test_custom_generic_disallowed tests/test_edge_cases.py::test_hashable_required tests/test_edge_cases.py::test_hashable_optional[1] tests/test_edge_cases.py::test_hashable_optional[None] tests/test_edge_cases.py::test_default_factory_called_once tests/test_edge_cases.py::test_default_factory_validator_child tests/test_edge_cases.py::test_cython_function_untouched tests/test_edge_cases.py::test_resolve_annotations_module_missing tests/test_edge_cases.py::test_iter_coverage tests/test_edge_cases.py::test_config_field_info tests/test_edge_cases.py::test_config_field_info_alias tests/test_edge_cases.py::test_config_field_info_merge tests/test_edge_cases.py::test_config_field_info_allow_mutation tests/test_edge_cases.py::test_arbitrary_types_allowed_custom_eq tests/test_edge_cases.py::test_bytes_subclass tests/test_edge_cases.py::test_int_subclass tests/test_edge_cases.py::test_model_issubclass tests/test_edge_cases.py::test_long_int tests/test_generics.py::test_generic_name tests/test_generics.py::test_double_parameterize_error tests/test_generics.py::test_value_validation tests/test_generics.py::test_methods_are_inherited tests/test_generics.py::test_config_is_inherited tests/test_generics.py::test_default_argument tests/test_generics.py::test_default_argument_for_typevar tests/test_generics.py::test_classvar tests/test_generics.py::test_non_annotated_field tests/test_generics.py::test_must_inherit_from_generic tests/test_generics.py::test_parameters_placed_on_generic tests/test_generics.py::test_parameters_must_be_typevar tests/test_generics.py::test_subclass_can_be_genericized tests/test_generics.py::test_parameter_count tests/test_generics.py::test_cover_cache tests/test_generics.py::test_cache_keys_are_hashable tests/test_generics.py::test_generic_config tests/test_generics.py::test_enum_generic tests/test_generics.py::test_generic tests/test_generics.py::test_alongside_concrete_generics tests/test_generics.py::test_complex_nesting tests/test_generics.py::test_required_value tests/test_generics.py::test_optional_value tests/test_generics.py::test_custom_schema tests/test_generics.py::test_child_schema tests/test_generics.py::test_custom_generic_naming tests/test_generics.py::test_nested tests/test_generics.py::test_partial_specification tests/test_generics.py::test_partial_specification_with_inner_typevar tests/test_generics.py::test_partial_specification_name tests/test_generics.py::test_partial_specification_instantiation tests/test_generics.py::test_partial_specification_instantiation_bounded tests/test_generics.py::test_typevar_parametrization tests/test_generics.py::test_multiple_specification tests/test_generics.py::test_generic_subclass_of_concrete_generic tests/test_generics.py::test_generic_model_pickle tests/test_generics.py::test_generic_model_from_function_pickle_fail tests/test_generics.py::test_generic_model_redefined_without_cache_fail tests/test_generics.py::test_generic_model_caching_detect_order_of_union_args_basic tests/test_generics.py::test_get_caller_frame_info tests/test_generics.py::test_get_caller_frame_info_called_from_module tests/test_generics.py::test_get_caller_frame_info_when_sys_getframe_undefined tests/test_generics.py::test_iter_contained_typevars tests/test_generics.py::test_nested_identity_parameterization tests/test_generics.py::test_replace_types tests/test_generics.py::test_replace_types_with_user_defined_generic_type_field tests/test_generics.py::test_replace_types_identity_on_unchanged tests/test_generics.py::test_deep_generic tests/test_generics.py::test_deep_generic_with_inner_typevar tests/test_generics.py::test_deep_generic_with_referenced_generic tests/test_generics.py::test_deep_generic_with_referenced_inner_generic tests/test_generics.py::test_deep_generic_with_multiple_typevars tests/test_generics.py::test_deep_generic_with_multiple_inheritance tests/test_generics.py::test_generic_with_referenced_generic_type_1 tests/test_generics.py::test_generic_with_referenced_nested_typevar tests/test_generics.py::test_generic_with_callable tests/test_generics.py::test_generic_with_partial_callable tests/test_generics.py::test_generic_recursive_models tests/test_generics.py::test_generic_enum tests/test_generics.py::test_generic_literal tests/test_generics.py::test_generic_enums tests/test_generics.py::test_generic_with_user_defined_generic_field tests/test_generics.py::test_generic_annotated tests/test_generics.py::test_generic_subclass tests/test_generics.py::test_generic_subclass_with_partial_application tests/test_generics.py::test_multilevel_generic_binding tests/test_generics.py::test_generic_subclass_with_extra_type tests/test_generics.py::test_multi_inheritance_generic_binding tests/test_generics.py::test_parse_generic_json tests/test_utils.py::test_import_module tests/test_utils.py::test_import_module_invalid tests/test_utils.py::test_import_no_attr tests/test_utils.py::test_display_as_type[str-str] tests/test_utils.py::test_display_as_type[string-str] tests/test_utils.py::test_display_as_type[value2-Union[str, tests/test_utils.py::test_display_as_type[list-list] tests/test_utils.py::test_lenient_issubclass tests/test_utils.py::test_lenient_issubclass_is_lenient tests/test_utils.py::test_truncate[object-<class tests/test_utils.py::test_truncate[abcdefghijklmnopqrstuvwxyz-'abcdefghijklmnopq\u2026'] tests/test_utils.py::test_truncate[input_value2-[0, tests/test_utils.py::test_unique_list[input_value0-output0] tests/test_utils.py::test_unique_list[input_value1-output1] tests/test_utils.py::test_unique_list[input_value2-output2] tests/test_utils.py::test_value_items tests/test_utils.py::test_value_items_merge[base0-override0-False-expected0] tests/test_utils.py::test_value_items_merge[None-None-False-None] tests/test_utils.py::test_value_items_merge[base2-override2-False-expected2] tests/test_utils.py::test_value_items_merge[base3-None-False-expected3] tests/test_utils.py::test_value_items_merge[None-override4-False-expected4] tests/test_utils.py::test_value_items_merge[None-override5-False-expected5] tests/test_utils.py::test_value_items_merge[base6-None-False-expected6] tests/test_utils.py::test_value_items_merge[base7-override7-False-expected7] tests/test_utils.py::test_value_items_merge[base8-override8-False-expected8] tests/test_utils.py::test_value_items_merge[base9-override9-False-expected9] tests/test_utils.py::test_value_items_merge[base10-override10-False-expected10] tests/test_utils.py::test_value_items_merge[base11-override11-False-expected11] tests/test_utils.py::test_value_items_merge[base12-override12-False-expected12] tests/test_utils.py::test_value_items_merge[base13-override13-False-expected13] tests/test_utils.py::test_value_items_merge[base14-override14-False-expected14] tests/test_utils.py::test_value_items_merge[base15-override15-False-expected15] tests/test_utils.py::test_value_items_merge[base16-override16-True-expected16] tests/test_utils.py::test_value_items_merge[None-None-True-None] tests/test_utils.py::test_value_items_merge[base18-override18-True-expected18] tests/test_utils.py::test_value_items_merge[base19-None-True-expected19] tests/test_utils.py::test_value_items_merge[None-override20-True-expected20] tests/test_utils.py::test_value_items_merge[None-override21-True-expected21] tests/test_utils.py::test_value_items_merge[base22-None-True-expected22] tests/test_utils.py::test_value_items_merge[base23-override23-True-expected23] tests/test_utils.py::test_value_items_merge[base24-override24-True-expected24] tests/test_utils.py::test_value_items_merge[base25-override25-True-expected25] tests/test_utils.py::test_value_items_merge[base26-override26-True-expected26] tests/test_utils.py::test_value_items_merge[base27-override27-True-expected27] tests/test_utils.py::test_value_items_merge[base28-override28-True-expected28] tests/test_utils.py::test_value_items_merge[base29-override29-True-expected29] tests/test_utils.py::test_value_items_merge[base30-override30-True-expected30] tests/test_utils.py::test_value_items_merge[base31-override31-True-expected31] tests/test_utils.py::test_value_items_merge[base32-True-False-True] tests/test_utils.py::test_value_items_merge[True-override33-False-expected33] tests/test_utils.py::test_value_items_merge[True-None-False-True] tests/test_utils.py::test_value_items_merge[base35-override35-False-expected35] tests/test_utils.py::test_value_items_error tests/test_utils.py::test_is_new_type tests/test_utils.py::test_new_type_supertype tests/test_utils.py::test_pretty tests/test_utils.py::test_pretty_color tests/test_utils.py::test_devtools_output tests/test_utils.py::test_devtools_output_validation_error tests/test_utils.py::test_deep_update[mapping0-updating_mapping0-expected_mapping0-extra tests/test_utils.py::test_deep_update[mapping1-updating_mapping1-expected_mapping1-values tests/test_utils.py::test_deep_update[mapping2-updating_mapping2-expected_mapping2-values tests/test_utils.py::test_deep_update[mapping3-updating_mapping3-expected_mapping3-deeply tests/test_utils.py::test_deep_update_is_not_mutating tests/test_utils.py::test_undefined_repr tests/test_utils.py::test_undefined_copy tests/test_utils.py::test_get_model tests/test_utils.py::test_version_info tests/test_utils.py::test_standard_version tests/test_utils.py::test_class_attribute tests/test_utils.py::test_all_literal_values tests/test_utils.py::test_path_type tests/test_utils.py::test_path_type_unknown tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[10] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[1.0] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[11] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[12] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[int] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[None] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[test_all_literal_values] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[len] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[obj8] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[<lambda>] tests/test_utils.py::test_smart_deepcopy_immutable_non_sequence[obj10] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection0] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection1] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection2] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection3] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection4] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection5] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection6] tests/test_utils.py::test_smart_deepcopy_empty_collection[empty_collection7] tests/test_utils.py::test_smart_deepcopy_collection[collection0] tests/test_utils.py::test_smart_deepcopy_collection[collection1] tests/test_utils.py::test_smart_deepcopy_collection[collection2] tests/test_utils.py::test_smart_deepcopy_collection[collection3] tests/test_utils.py::test_smart_deepcopy_collection[collection4] tests/test_utils.py::test_smart_deepcopy_collection[collection5] tests/test_utils.py::test_smart_deepcopy_collection[collection6] tests/test_utils.py::test_smart_deepcopy_collection[collection7] tests/test_utils.py::test_smart_deepcopy_error[TypeError] tests/test_utils.py::test_smart_deepcopy_error[ValueError] tests/test_utils.py::test_smart_deepcopy_error[RuntimeError] tests/test_utils.py::test_get_origin[input_value0-Annotated] tests/test_utils.py::test_get_origin[input_value1-Callable] tests/test_utils.py::test_get_origin[input_value2-dict] tests/test_utils.py::test_get_origin[input_value3-list] tests/test_utils.py::test_get_origin[input_value4-output_value4] tests/test_utils.py::test_get_origin[int-None] tests/test_utils.py::test_resolve_annotations_no_module tests/test_utils.py::test_all_identical tests/test_utils.py::test_undefined_pickle tests/test_utils.py::test_on_lower_camel_zero_length tests/test_utils.py::test_on_lower_camel_one_length tests/test_utils.py::test_on_lower_camel_many_length