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

Function test_module_level_setup

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

Source from the content-addressed store, hash-verified

159
160
161def test_module_level_setup(pytester: Pytester) -> None:
162 pytester.makepyfile(
163 """
164 from nose.tools import with_setup
165 items = {}
166
167 def setup():
168 items.setdefault("setup", []).append("up")
169
170 def teardown():
171 items.setdefault("setup", []).append("down")
172
173 def setup2():
174 items.setdefault("setup2", []).append("up")
175
176 def teardown2():
177 items.setdefault("setup2", []).append("down")
178
179 def test_setup_module_setup():
180 assert items["setup"] == ["up"]
181
182 def test_setup_module_setup_again():
183 assert items["setup"] == ["up"]
184
185 @with_setup(setup2, teardown2)
186 def test_local_setup():
187 assert items["setup"] == ["up"]
188 assert items["setup2"] == ["up"]
189
190 @with_setup(setup2, teardown2)
191 def test_local_setup_again():
192 assert items["setup"] == ["up"]
193 assert items["setup2"] == ["up", "down", "up"]
194 """
195 )
196 result = pytester.runpytest("-p", "nose")
197 result.stdout.fnmatch_lines(["*4 passed*"])
198
199
200def test_nose_style_setup_teardown(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