MCPcopy
hub / github.com/pydantic/pydantic / test_plugin_path_complex

Function test_plugin_path_complex

tests/test_plugins.py:466–502  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

464
465
466def test_plugin_path_complex() -> None:
467 paths: list[tuple(str, str)] = []
468
469 class CustomOnValidatePython(ValidatePythonHandlerProtocol):
470 pass
471
472 class Plugin:
473 def new_schema_validator(self, schema, schema_type, schema_type_path, schema_kind, config, plugin_settings):
474 paths.append((schema_type.__name__, schema_type_path, schema_kind))
475 return CustomOnValidatePython(), None, None
476
477 plugin = Plugin()
478 with install_plugin(plugin):
479
480 def foo():
481 class Model1(BaseModel):
482 pass
483
484 def bar():
485 class Model2(BaseModel):
486 pass
487
488 foo()
489 bar()
490
491 assert paths == [
492 (
493 'Model1',
494 SchemaTypePath('tests.test_plugins', 'test_plugin_path_complex.<locals>.foo.<locals>.Model1'),
495 'BaseModel',
496 ),
497 (
498 'Model2',
499 SchemaTypePath('tests.test_plugins', 'test_plugin_path_complex.<locals>.bar.<locals>.Model2'),
500 'BaseModel',
501 ),
502 ]

Callers

nothing calls this directly

Calls 5

SchemaTypePathClass · 0.90
install_pluginFunction · 0.85
PluginClass · 0.70
fooFunction · 0.70
barFunction · 0.70

Tested by

no test coverage detected