From e769a3c0899e24192edeb35e61ba7d8685812aac Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Thu, 16 Nov 2023 15:30:24 +0100 Subject: [PATCH] test: fixing py tests --- .github/workflows/prepare_environment.sh | 11 ----------- .github/workflows/python2-3-app.yml | 20 ++++++++++---------- src/db12/benchmark.py | 2 +- 3 files changed, 11 insertions(+), 22 deletions(-) delete mode 100755 .github/workflows/prepare_environment.sh diff --git a/.github/workflows/prepare_environment.sh b/.github/workflows/prepare_environment.sh deleted file mode 100755 index 892a886..0000000 --- a/.github/workflows/prepare_environment.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -PYTHON_VERSION=$1 - -conda create --quiet -c conda-forge -c free -n test-env \ - python="$PYTHON_VERSION" \ - "pytest>=4.6" pylint pytest-cov pytest-mock pycodestyle \ - mock setuptools setuptools_scm wheel -source "${CONDA}/bin/activate" test-env -pip install ".[testing]" diff --git a/.github/workflows/python2-3-app.yml b/.github/workflows/python2-3-app.yml index 764e6ed..04eb19d 100644 --- a/.github/workflows/python2-3-app.yml +++ b/.github/workflows/python2-3-app.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest if: github.event_name != 'push' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-python@v2 with: python-version: '3.9' @@ -27,20 +27,20 @@ jobs: - 3.9 steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - - - uses: actions/checkout@v2 - - name: Prepare environment - run: .github/workflows/prepare_environment.sh ${{ matrix.python_version }} + - uses: actions/checkout@v4 + - name: prepare environment + run: | + conda config --set add_pip_as_python_dependency false + conda create -c conda-forge -n db12 python=${{ matrix.python_version }} - name: Run pylint run: | - . "${CONDA}/bin/activate" test-env + eval "$(conda shell.bash hook)" && conda activate db12 + conda install -c conda-forge pylint pylint -E src/db12/ tests/ - name: Run pytest run: | - . "${CONDA}/bin/activate" test-env + eval "$(conda shell.bash hook)" && conda activate db12 + conda install -c conda-forge pytest pytest tests diff --git a/src/db12/benchmark.py b/src/db12/benchmark.py index 30d44d5..82a11ff 100644 --- a/src/db12/benchmark.py +++ b/src/db12/benchmark.py @@ -64,7 +64,7 @@ def single_dirac_benchmark(iterations_num=1, measured_copies=None, correction=Tr it_1 += 1 - cput = sum(end[:4]) - sum(start[:4]) + cput = sum(end[:4]) - sum(start[:4]) # pylint: disable=used-before-assignment wall = end[4] - start[4] if not cput: