From c6e3343f1a0086950e8fdc1d5d27a647670df386 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Thu, 16 Nov 2023 15:33:00 +0100 Subject: [PATCH] test: fixing py tests --- .github/workflows/prepare_environment.sh | 11 ----------- .github/workflows/python2-3-app.yml | 21 +++++++++++---------- environment.yml | 4 ---- src/db12/benchmark.py | 2 +- 4 files changed, 12 insertions(+), 26 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..69d5d0f 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' @@ -18,6 +18,7 @@ jobs: build: runs-on: ubuntu-latest + if: github.event_name != 'push' strategy: fail-fast: False matrix: @@ -27,20 +28,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 pytest mock 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 pylint pytest mock pytest tests diff --git a/environment.yml b/environment.yml index 8e61232..4cdf5bc 100644 --- a/environment.yml +++ b/environment.yml @@ -3,8 +3,4 @@ name: db12 dependencies: - python =3.9 - future - - mock - pre-commit - - pylint - - pytest - - pytest-mock 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: