()
| 91 | |
| 92 | |
| 93 | def test_code_getargs() -> None: |
| 94 | def f1(x): |
| 95 | raise NotImplementedError() |
| 96 | |
| 97 | c1 = Code.from_function(f1) |
| 98 | assert c1.getargs(var=True) == ("x",) |
| 99 | |
| 100 | def f2(x, *y): |
| 101 | raise NotImplementedError() |
| 102 | |
| 103 | c2 = Code.from_function(f2) |
| 104 | assert c2.getargs(var=True) == ("x", "y") |
| 105 | |
| 106 | def f3(x, **z): |
| 107 | raise NotImplementedError() |
| 108 | |
| 109 | c3 = Code.from_function(f3) |
| 110 | assert c3.getargs(var=True) == ("x", "z") |
| 111 | |
| 112 | def f4(x, *y, **z): |
| 113 | raise NotImplementedError() |
| 114 | |
| 115 | c4 = Code.from_function(f4) |
| 116 | assert c4.getargs(var=True) == ("x", "y", "z") |
| 117 | |
| 118 | def f5(x, *y, **z): |
| 119 | a1 = a2 = a3 = a4 = a5 = a6 = 1 # noqa: F841 |
| 120 | |
| 121 | c5 = Code.from_function(f5) |
| 122 | f5(1, 2, 3, z=4) # cover function body |
| 123 | assert c5.getargs(var=True) == ("x", "y", "z") |
| 124 | |
| 125 | def f6(x, *y, kw=1, **z): |
| 126 | a1 = a2 = a3 = a4 = a5 = a6 = 1 # noqa: F841 |
| 127 | |
| 128 | c6 = Code.from_function(f6) |
| 129 | f6(1, 2, kw=3, z=4) # cover function body |
| 130 | assert c6.getargs(var=True) == ("x", "kw", "y", "z") |
| 131 | |
| 132 | |
| 133 | def test_frame_getargs() -> None: |
nothing calls this directly
no test coverage detected