'Test that auto-use fixtures work properly with doctest files.
See #1057 and #1100.'

@pytest.mark.parametrize('scope', SCOPES)
@pytest.mark.parametrize('autouse', [True, False])
@pytest.mark.parametrize('use_fixture_in_doctest', [True, False])
def test_fixture_module_doctest_scopes(self, testdir, scope, autouse, use_fixture_in_doctest):

    testdir.makeconftest('\n                                                import    pytest\n\n                                                @pytest.fixture(autouse={autouse},    scope="{scope}")\n                                                def    auto(request):\n                                                                return    99\n                                '.format(scope=scope, autouse=autouse))
    if use_fixture_in_doctest:
        testdir.maketxtfile(test_doc="\n                                                                >>>    getfixture('auto')\n                                                                99\n                                                ")
    else:
        testdir.maketxtfile(test_doc='\n                                                                >>>    1    +    1\n                                                                2\n                                                ')
    result = testdir.runpytest('--doctest-modules')
    assert ('FAILURES' not in str(result.stdout.str()))
    result.stdout.fnmatch_lines(['*===    1    passed    in    *'])
