Test that auto-use fixtures work properly with doctest modules. See #1057 and #1100.
(self, pytester, scope, enable_doctest)
| 1248 | @pytest.mark.parametrize("scope", SCOPES) |
| 1249 | @pytest.mark.parametrize("enable_doctest", [True, False]) |
| 1250 | def test_fixture_scopes(self, pytester, scope, enable_doctest): |
| 1251 | """Test that auto-use fixtures work properly with doctest modules. |
| 1252 | See #1057 and #1100. |
| 1253 | """ |
| 1254 | pytester.makeconftest( |
| 1255 | """ |
| 1256 | import pytest |
| 1257 | |
| 1258 | @pytest.fixture(autouse=True, scope="{scope}") |
| 1259 | def auto(request): |
| 1260 | return 99 |
| 1261 | """.format( |
| 1262 | scope=scope |
| 1263 | ) |
| 1264 | ) |
| 1265 | pytester.makepyfile( |
| 1266 | test_1=''' |
| 1267 | def test_foo(): |
| 1268 | """ |
| 1269 | >>> getfixture('auto') + 1 |
| 1270 | 100 |
| 1271 | """ |
| 1272 | def test_bar(): |
| 1273 | assert 1 |
| 1274 | ''' |
| 1275 | ) |
| 1276 | params = ("--doctest-modules",) if enable_doctest else () |
| 1277 | passes = 3 if enable_doctest else 2 |
| 1278 | result = pytester.runpytest(*params) |
| 1279 | result.stdout.fnmatch_lines(["*=== %d passed in *" % passes]) |
| 1280 | |
| 1281 | @pytest.mark.parametrize("scope", SCOPES) |
| 1282 | @pytest.mark.parametrize("autouse", [True, False]) |
nothing calls this directly
no test coverage detected