Why is pytest_sessionstart in conftest.py causing 'Fixtures are not meant to be called directly' error?
See original GitHub issueHi,
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')
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
a pytest hook is never a fixture
so by marking the
pytest_sessionstart
hook as fixture instead of apytest.hookimpl()
you literally shoot your own footOops, ok apologies…
Cheers @RonnyPfannschmidt and @nicoddemus. That got me up and running 😃