Skip to content

Commit

Permalink
test: fixing py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Nov 16, 2023
1 parent 6efc7ec commit 8c2cf14
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 42 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/prepare_environment.sh

This file was deleted.

56 changes: 35 additions & 21 deletions .github/workflows/python2-3-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -16,31 +16,45 @@ jobs:
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure

build:
runs-on: ubuntu-latest
pytest:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.repository == 'DIRACGrid/db12'

strategy:
fail-fast: False
matrix:
python_version:
- 2.7
- 3.6
- 3.9
python:
- 2.7.18
- 3.6.15
- 3.9.17
- 3.11.4

container: python:${{ matrix.python }}-slim
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Installing dependencies
run: |
python -m pip install pytest mock
pip install -e .
- name: Run pytest
run: pytest

- uses: actions/checkout@v2
- name: Prepare environment
run: .github/workflows/prepare_environment.sh ${{ matrix.python_version }}
pylint:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.repository == 'DIRACGrid/db12'
timeout-minutes: 10

- name: Run pylint
run: |
. "${CONDA}/bin/activate" test-env
pylint -E src/db12/ tests/
strategy:
matrix:
python:
- 2.7.18
- 3.6.15
- 3.9.17

- name: Run pytest
container: python:${{ matrix.python }}-slim
steps:
- uses: actions/checkout@v4
- name: Installing dependencies
run: |
. "${CONDA}/bin/activate" test-env
pytest tests
python -m pip install pylint pytest mock
- name: Run pylint
run: pylint -E src/db12 tests
6 changes: 2 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: db12
dependencies:
- python =3.9
- future
- mock
- pre-commit
- pylint
- pytest
- pytest-mock
- pip:
- -e .
15 changes: 11 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

# Enable setuptools_scm to compute the version number from the most recent tag
# https://github.com/pypa/setuptools_scm/#pyprojecttoml-usage
[tool.setuptools_scm]
# Avoid letting setuptools_scm use old style tags (i.e. vXrYpZ)
git_describe_command = "git describe --dirty --tags --long --match *[0-9].[0-9]* --exclude v[0-9]r* --exclude v[0-9][0-9]r*"

[tool.isort]
profile = "black"

2 changes: 1 addition & 1 deletion src/db12/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_DB12.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Unit test for DB12"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import pytest
import mock

from db12 import single_dirac_benchmark
from db12 import multiple_dirac_benchmark
Expand Down

0 comments on commit 8c2cf14

Please sign in to comment.