mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-02 18:13:04 +00:00
Use intelligent scheduling to improve online test performance
This commit is contained in:
@@ -11,6 +11,7 @@ from unittest.mock import MagicMock, Mock, PropertyMock
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import pytest
|
||||
from xdist.scheduler.loadscope import LoadScopeScheduling
|
||||
|
||||
from freqtrade import constants
|
||||
from freqtrade.commands import Arguments
|
||||
@@ -56,6 +57,27 @@ def pytest_configure(config):
|
||||
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):
|
||||
"""Check if line is found on some caplog's message."""
|
||||
return any(line == message for message in logs.messages)
|
||||
|
||||
Reference in New Issue
Block a user