35 lines
916 B
Python
35 lines
916 B
Python
import pytest
|
|
from _pytest.runner import runtestprotocol
|
|
|
|
|
|
def pytest_ignore_collect(path, config):
|
|
if path.basename.startswith("test_cypress_"):
|
|
return True
|
|
|
|
|
|
@pytest.hookimpl(tryfirst=True)
|
|
def pytest_collection_modifyitems(config, items):
|
|
parallel_items = []
|
|
serial_items = []
|
|
|
|
for item in items:
|
|
if "serial" in item.keywords:
|
|
serial_items.append(item)
|
|
else:
|
|
parallel_items.append(item)
|
|
|
|
# Modify the collection to run serial tests first
|
|
config.serial_items = serial_items
|
|
items[:] = parallel_items
|
|
|
|
|
|
@pytest.hookimpl(tryfirst=True)
|
|
def pytest_sessionfinish(session, exitstatus):
|
|
config = session.config
|
|
if hasattr(config, "serial_items") and config.serial_items:
|
|
serial_items = config.serial_items
|
|
|
|
# Run serial tests one by one
|
|
for item in serial_items:
|
|
runtestprotocol(item, nextitem=None)
|