Use intelligent scheduling to improve online test performance

This commit is contained in:
Matthias
2023-12-24 16:27:18 +01:00
parent 03fb204408
commit fc13a99b33
+22
View File
@@ -11,6 +11,7 @@ from unittest.mock import MagicMock, Mock, PropertyMock
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import pytest import pytest
from xdist.scheduler.loadscope import LoadScopeScheduling
from freqtrade import constants from freqtrade import constants
from freqtrade.commands import Arguments from freqtrade.commands import Arguments
@@ -56,6 +57,27 @@ def pytest_configure(config):
setattr(config.option, 'markexpr', 'not longrun') setattr(config.option, 'markexpr', 'not longrun')
class FixtureScheduler(LoadScopeScheduling):
# Based on the suggestion in
# https://github.com/pytest-dev/pytest-xdist/issues/18
def _split_scope(self, nodeid):
if 'exchange_online' in nodeid:
try:
# Extract exchange ID from nodeid
exchange_id = nodeid.split('[')[1].split('-')[0].rstrip(']')
return exchange_id
except Exception as e:
print(e)
pass
return nodeid
def pytest_xdist_make_scheduler(config, log):
return FixtureScheduler(config, log)
def log_has(line, logs): def log_has(line, logs):
"""Check if line is found on some caplog's message.""" """Check if line is found on some caplog's message."""
return any(line == message for message in logs.messages) return any(line == message for message in logs.messages)