diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f8ece4cc..953cd6c07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,6 @@ jobs: - name: pip cache (linux) uses: actions/cache@v3 - if: runner.os == 'Linux' with: path: ~/.cache/pip key: test-${{ matrix.os }}-${{ matrix.python-version }}-pip @@ -55,7 +54,6 @@ jobs: cd build_helpers && ./install_ta-lib.sh ${HOME}/dependencies/; cd .. - name: Installation - *nix - if: runner.os == 'Linux' run: | python -m pip install --upgrade pip wheel export LD_LIBRARY_PATH=${HOME}/dependencies/lib:$LD_LIBRARY_PATH @@ -378,7 +376,6 @@ jobs: - name: pip cache (linux) uses: actions/cache@v3 - if: runner.os == 'Linux' with: path: ~/.cache/pip key: test-${{ matrix.os }}-${{ matrix.python-version }}-pip @@ -389,7 +386,6 @@ jobs: cd build_helpers && ./install_ta-lib.sh ${HOME}/dependencies/; cd .. - name: Installation - *nix - if: runner.os == 'Linux' run: | python -m pip install --upgrade pip wheel export LD_LIBRARY_PATH=${HOME}/dependencies/lib:$LD_LIBRARY_PATH @@ -402,7 +398,7 @@ jobs: env: CI_WEB_PROXY: http://152.67.78.211:13128 run: | - pytest --random-order --cov=freqtrade --cov-config=.coveragerc --longrun + pytest --random-order --longrun --durations 20 -n auto --dist loadscope # Notify only once - when CI completes (and after deploy) in case it's successfull diff --git a/requirements-dev.txt b/requirements-dev.txt index 06ca4411a..7cc93feb8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -15,6 +15,7 @@ pytest-asyncio==0.21.1 pytest-cov==4.1.0 pytest-mock==3.12.0 pytest-random-order==1.1.0 +pytest-xdist==3.5.0 isort==5.13.2 # For datetime mocking time-machine==2.13.0 diff --git a/tests/conftest.py b/tests/conftest.py index 2d7a805b1..80d164ee4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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)