Skip to content

Commit

Permalink
Fix pytest and tox (#98)
Browse files Browse the repository at this point in the history
* Fix pytest and tox

* Remove explicitly exporting JANUS_PATH in CI

---------

Co-authored-by: ElliottKasoar <ElliottKasoar@users.noreply.github.com>
  • Loading branch information
ElliottKasoar and ElliottKasoar authored Mar 19, 2024
1 parent 99ab066 commit bc349a5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ jobs:
run: |
poetry env use ${{ matrix.python-version }}
poetry install --with dev
echo "JANUS_PATH=$(poetry run which janus)" >> $GITHUB_ENV
- name: Run test suite

env:
# show timings of test
PYTEST_ADDOPTS: "--durations=0"
JANUS_PATH: ${{ env.JANUS_PATH }}
run: poetry run pytest --cov aiida_mlip --cov-append .

- name: Report coverage to Coveralls
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ filterwarnings = [
"ignore::DeprecationWarning:plumpy:",
"ignore::DeprecationWarning:yaml:",
]
pythonpath = ["."]

[tool.coverage.run]
# Configuration of [coverage.py](https://coverage.readthedocs.io)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
from pathlib import Path
import shutil

import pytest

Expand Down Expand Up @@ -93,7 +94,7 @@ def janus_code(aiida_local_code_factory):
`Code`
The janus code instance.
"""
janus_path = os.environ.get("JANUS_PATH")
janus_path = shutil.which("janus") or os.environ.get("JANUS_PATH")
return aiida_local_code_factory(executable=janus_path, entry_point="janus.sp")


Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ usedevelop=True

[testenv:py{39,310,311,312}]
description = Run the test suite against Python versions
allowlist_externals = poetry, sh
allowlist_externals = poetry
commands_pre = poetry install --no-root --sync
# Export path to janus executable installed in tox environment before running pytest
commands = sh -c 'export JANUS_PATH=$(which janus); exec "$@"' _ poetry run pytest --cov aiida_mlip --import-mode importlib
commands = poetry run pytest {posargs} --cov aiida_mlip --import-mode importlib

[testenv:pre-commit]
description = Run the pre-commit checks
Expand Down

0 comments on commit bc349a5

Please sign in to comment.