-
Notifications
You must be signed in to change notification settings - Fork 61
session-scope fixtures aren't honored #26
Comments
I wonder if pytest-xdist could provide a new session scope called The purpose of actually making an extra |
This is somehow expected in multiprocess operation mode (workers>1), but in thread mode (tests-per-worker>1) scopes "module" and "session" should be honored - the fixture should be shared. |
In
import pytest
from threading import Lock
mutex = Lock()
a = None
@pytest.fixture(scope='session')
def variable_a():
mutex.acquire()
global a
if not a:
a = object()
mutex.release()
return a
def test_1(variable_a):
assert variable_a == 0
def test_2(variable_a):
assert variable_a == 0
def test_3(variable_a):
assert variable_a == 0
def test_4(variable_a):
assert variable_a == 0
> pytest test.py --tests-per-worker 4
FAILED test.py::test_4 - assert <object object at 0x7f9362271370> == 0
FAILED test.py::test_3 - assert <object object at 0x7f9362271370> == 0
FAILED test.py::test_2 - assert <object object at 0x7f9362271370> == 0
FAILED test.py::test_1 - assert <object object at 0x7f9362271370> == 0 They are all one object, but can't use it in |
Any news on this? I can confirm session fixtures are not honoured even in single-worker (multi-threaded) mode |
Any update here? |
Similar to what happens with
pytest-xdist
: pytest-dev/pytest-xdist#271The text was updated successfully, but these errors were encountered: