|
15 | 15 | import pytest |
16 | 16 | import logging |
17 | 17 | import os |
| 18 | +from packaging.version import Version |
18 | 19 |
|
19 | 20 | import numpy as np |
20 | 21 | import MDAnalysis as mda |
@@ -219,9 +220,32 @@ async def test_run_continue_remove_with_gromacs( |
219 | 220 | n_files_beauty = 3 |
220 | 221 | # and we should have 0-2 concatenated out-trajs in the directory |
221 | 222 | # 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) |
225 | 249 | for steps in [n_steps, continuation_n_steps] |
226 | 250 | ) |
227 | 251 | # the times we actually did a call to gmx mdrun, i.e. for the cases |
|
0 commit comments