MCPcopy
hub / github.com/pytest-dev/pytest / test_code_getargs

Function test_code_getargs

testing/code/test_code.py:93–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92
93def 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
133def test_frame_getargs() -> None:

Callers

nothing calls this directly

Calls 4

f5Function · 0.85
f6Function · 0.85
from_functionMethod · 0.80
getargsMethod · 0.45

Tested by

no test coverage detected