Skip to content

Commit ea60cd7

Browse files
authored
Merge pull request #50 from hejung/fix_tests
(temporarily) pin gromacs to 2025 until mdanalysis can read the new tpr-format also fix tests for Propagators remove_parts methods, they now work on mdanalysis v>=2.9 and when using filelock or fasteners for locking
2 parents 97ab237 + 0d9c46b commit ea60cd7

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
conda-remove-defaults: true
3838
- name: Install
3939
run: |
40-
conda install gromacs
40+
conda install "gromacs<2026"
4141
python -m pip install -e .\[tests-all\]
4242
- name: List versions
4343
run: |

tests/trajectory/test_propagate.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pytest
1616
import logging
1717
import os
18+
from packaging.version import Version
1819

1920
import numpy as np
2021
import MDAnalysis as mda
@@ -219,9 +220,32 @@ async def test_run_continue_remove_with_gromacs(
219220
n_files_beauty = 3
220221
# and we should have 0-2 concatenated out-trajs in the directory
221222
# depending on how many times we ran with n_steps != 0
222-
# for each run/out_traj we the hidden offsets file and the hidden lock
223-
# file from mdanalysis
224-
n_files_beauty += sum(3 * int(steps != 0)
223+
# for each run/out_traj we have the hidden offsets file and the hidden
224+
# lock file from mdanalysis XDR-reader/writer depending on the MDAnalysis
225+
# and filelock versions, so first figure out the filelock/mdanalysis version:
226+
# - filelock is used since mdanalysis 2.9.0 (before that fasteners since
227+
# mda version 2.2.0 and fasteners does not remove lock files)
228+
# - filelock removes lockfiles on win with filelock version >= 3.25.1
229+
# - filelock removes lockfiles on unix with filelock version >= 3.20.4
230+
try:
231+
import filelock
232+
except ImportError:
233+
# filelock not installed so mdanalysis version < 2.9
234+
# if mda version >= 2.2.0 we have lockfiles
235+
files_per_traj = (3 if Version(mda.__version__) >= Version("2.2.0")
236+
else 2)
237+
else:
238+
# lockfile used instead of fasteners
239+
if os.name == "posix":
240+
files_per_traj = (
241+
2 if Version(filelock.__version__) >= Version("3.20.4")
242+
else 3)
243+
elif os.name == "nt":
244+
files_per_traj = (
245+
2 if Version(filelock.__version__) >= Version("3.25.1")
246+
else 3)
247+
# now the actual tests
248+
n_files_beauty += sum(files_per_traj * int(steps != 0)
225249
for steps in [n_steps, continuation_n_steps]
226250
)
227251
# the times we actually did a call to gmx mdrun, i.e. for the cases

0 commit comments

Comments
 (0)