File: test_plugin.py

package info (click to toggle)
pydantic 2.12.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,640 kB
  • sloc: python: 75,984; javascript: 181; makefile: 115; sh: 38
file content (24 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os

import pytest

pytestmark = pytest.mark.skipif(not os.getenv('TEST_PLUGIN'), reason='Test only with `TEST_PLUGIN` env var set.')


def test_plugin_usage():
    from pydantic import BaseModel

    class MyModel(BaseModel):
        x: int
        y: str

    m = MyModel(x='10', y='hello')
    assert m.x == 10
    assert m.y == 'hello'

    from example_plugin import log

    assert log == [
        "on_enter args=({'x': '10', 'y': 'hello'},) kwargs={'self_instance': MyModel()}",
        "on_success result=x=10 y='hello'",
    ]