'Test that session fixtures are initialized for doctest modules (#768)'

def test_doctest_module_session_fixture(self, testdir):

    testdir.makeconftest("\n                                                import    pytest\n                                                import    sys\n\n                                                @pytest.yield_fixture(autouse=True,    scope='session')\n                                                def    myfixture():\n                                                                assert    not    hasattr(sys,    'pytest_session_data')\n                                                                sys.pytest_session_data    =    1\n                                                                yield\n                                                                del    sys.pytest_session_data\n                                ")
    testdir.makepyfile(foo="\n                                                import    sys\n\n                                                def    foo():\n                                                        '''\n                                                        >>>    assert    sys.pytest_session_data    ==    1\n                                                        '''\n\n                                                def    bar():\n                                                        '''\n                                                        >>>    assert    sys.pytest_session_data    ==    1\n                                                        '''\n                                ")
    result = testdir.runpytest('--doctest-modules')
    result.stdout.fnmatch_lines('*2    passed*')
