MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_nose_setup_partial

Function test_nose_setup_partial

testing/test_nose.py:126–158  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

124
125
126def test_nose_setup_partial(pytester: Pytester) -> None:
127 pytest.importorskip("functools")
128 p = pytester.makepyfile(
129 """
130 from functools import partial
131
132 values = []
133
134 def my_setup(x):
135 a = x
136 values.append(a)
137
138 def my_teardown(x):
139 b = x
140 values.append(b)
141
142 my_setup_partial = partial(my_setup, 1)
143 my_teardown_partial = partial(my_teardown, 2)
144
145 def test_hello():
146 print(values)
147 assert values == [1]
148
149 def test_world():
150 print(values)
151 assert values == [1,2]
152
153 test_hello.setup = my_setup_partial
154 test_hello.teardown = my_teardown_partial
155 """
156 )
157 result = pytester.runpytest(p, "-p", "nose")
158 result.stdout.fnmatch_lines(["*2 passed*"])
159
160
161def test_module_level_setup(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected