(create_module)
| 147 | |
| 148 | |
| 149 | def test_positional_only(create_module): |
| 150 | with pytest.warns(PydanticDeprecatedSince20): |
| 151 | module = create_module( |
| 152 | # language=Python |
| 153 | """ |
| 154 | from pydantic.deprecated.decorator import validate_arguments |
| 155 | |
| 156 | @validate_arguments |
| 157 | def foo(a, b, /, c=None): |
| 158 | return f'{a}, {b}, {c}' |
| 159 | """ |
| 160 | ) |
| 161 | assert module.foo(1, 2) == '1, 2, None' |
| 162 | assert module.foo(1, 2, 44) == '1, 2, 44' |
| 163 | assert module.foo(1, 2, c=44) == '1, 2, 44' |
| 164 | with pytest.raises(TypeError, match="positional-only argument passed as keyword argument: 'b'"): |
| 165 | module.foo(1, b=2) |
| 166 | with pytest.raises(TypeError, match="positional-only arguments passed as keyword arguments: 'a', 'b'"): |
| 167 | module.foo(a=1, b=2) |
| 168 | |
| 169 | |
| 170 | def test_args_name(): |
nothing calls this directly
no test coverage detected