Skip to content

Why is pytest_sessionstart in conftest.py causing 'Fixtures are not meant to be called directly' error? #4644

@dcs3spp

Description

@dcs3spp

Hi,

Can anyone explain why the pytest_sessionstart fixture in conftest.py is causing an error relating to Fixtures are not meant to be called directly?

I have searched the root directory and there are no further references to pytest_sessionstart so the fixture is not being called anywhere else within the project.

I have installed the project source code from requirements.txt file using pip install -r requirements.txt

The conftest.py file is listed below. If I uncomment the pytest_sessionstart fixture tests run!

I am using pytest 4.1.1 on OSX High Sierra 10.13.6.

import locale
import logging
import pytest

from pyramid_core.testing import FileServerFactory
from pyramid_core.testing.factories import TestEnvironment

def pytest_configure(config):
    TestEnvironment(config)

def pytest_addoption(parser):
    parser.addini("file.server.path", "file server")

@pytest.fixture(scope='session')
def docker_compose_files(pytestconfig):
    config = FileServerFactory.get_config(pytestconfig)
    return config.validated_files

@pytest.fixture(autouse=True, scope='session')
def pytest_sessionstart( ):
    locale.setlocale(locale.LC_TIME, '')
    logging.basicConfig(level=logging.INFO,
        format='%(asctime)s    %(levelname)s    %(module)s::%(funcName)s line %(lineno)s %(message)s',
        datefmt='%x:%X')

    logging.info('datetime locale set to {}'.format(locale.getlocale(category=locale.LC_TIME)))
    logging.info('logging configured')

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions