|
1 |
| -from inspect import signature |
| 1 | +from inspect import Parameter, Signature, signature |
2 | 2 |
|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 | from ..test_signatures import _test_inspectable_func
|
6 | 6 |
|
7 | 7 |
|
8 |
| -@pytest.mark.xfail("not implemented") |
| 8 | +def stub(foo, /, bar=None, *, baz=None): |
| 9 | + pass |
| 10 | + |
| 11 | + |
| 12 | +stub_sig = signature(stub) |
| 13 | + |
| 14 | + |
| 15 | +def test_does_not_raise_on_interopable_kw_arg(): |
| 16 | + def stub_without_kwonly(foo, /, bar=None, baz=None): |
| 17 | + pass |
| 18 | + |
| 19 | + _test_inspectable_func( |
| 20 | + signature(stub_without_kwonly), |
| 21 | + stub_sig, |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +@pytest.mark.parametrize( |
| 26 | + "sig", |
| 27 | + [ |
| 28 | + Signature( |
| 29 | + [ |
| 30 | + Parameter("foo", Parameter.POSITIONAL_ONLY), |
| 31 | + Parameter("bar", Parameter.POSITIONAL_ONLY), |
| 32 | + Parameter("baz", Parameter.KEYWORD_ONLY), |
| 33 | + ] |
| 34 | + ), |
| 35 | + Signature( |
| 36 | + [ |
| 37 | + Parameter("foo", Parameter.POSITIONAL_ONLY), |
| 38 | + Parameter("bar", Parameter.KEYWORD_ONLY), |
| 39 | + Parameter("baz", Parameter.KEYWORD_ONLY), |
| 40 | + ] |
| 41 | + ), |
| 42 | + ], |
| 43 | +) |
| 44 | +def test_raises_on_bad_sig(sig): |
| 45 | + with pytest.raises(AssertionError): |
| 46 | + _test_inspectable_func(sig, stub_sig) |
| 47 | + |
| 48 | + |
| 49 | +@pytest.mark.xfail(reason="not implemented") |
9 | 50 | def test_kwonly():
|
10 | 51 | def func(*, foo=None, bar=None):
|
11 | 52 | pass
|
|
0 commit comments