Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani committed Oct 18, 2023
1 parent 0dac44e commit 4edb244
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_plugins.py
Expand Up @@ -372,3 +372,34 @@ def new_schema_validator(self, schema, path, config, plugin_settings):
plugin = Plugin()
with install_plugin(plugin):
create_model('FooModel', foo=(str, ...), bar=(int, 123))


def test_plugin_path_complex() -> None:
paths: list[str] = []

class CustomOnValidatePython(ValidatePythonHandlerProtocol):
pass

class Plugin:
def new_schema_validator(self, schema, path, config, plugin_settings):
paths.append(path)
return CustomOnValidatePython(), None, None

plugin = Plugin()
with install_plugin(plugin):

def foo():
class Model(BaseModel):
pass

def bar():
class Model(BaseModel):
pass

foo()
bar()

assert paths == [
'tests.test_plugins:test_plugin_path_complex.<locals>.foo.<locals>.Model',
'tests.test_plugins:test_plugin_path_complex.<locals>.bar.<locals>.Model',
]

0 comments on commit 4edb244

Please sign in to comment.