(pytester: Pytester)
| 159 | |
| 160 | |
| 161 | def 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 | |
| 200 | def test_nose_style_setup_teardown(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected