Skip to content
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Chronological list of authors
- Mohammad Ayaan
- Khushi Phougat
- Kushagar Garg
- Jeremy M. G. Leung

External code
-------------
Expand Down
3 changes: 2 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ The rules for this file:

-------------------------------------------------------------------------------
??/??/?? IAlibay, orbeckst, marinegor, tylerjereddy, ljwoods2, marinegor,
spyke7, talagayev, tanii1125, BradyAJohnston, hejamu
spyke7, talagayev, tanii1125, BradyAJohnston, hejamu, jeremyleung521

* 2.11.0

Fixes
* Drop/Replace lock file test in test_xdr (Issue #5236, PR #5237)
* HydrogenBondAnalysis: Fixed `count_by_time()` when using `run(FrameIterator)` that
results in `self.start` and `self.end` being None (Issue #5200, PR #5202)
* NoJump shows a more informative message and fails when applied
Expand Down
32 changes: 19 additions & 13 deletions testsuite/MDAnalysisTests/coordinates/test_xdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@

import re
import os
import sys
import shutil
import subprocess
import time
import sys
from filelock import FileLock
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -59,10 +58,8 @@
)

import MDAnalysis as mda
from MDAnalysis.coordinates.base import Timestep
from MDAnalysis.coordinates import XDR
from MDAnalysisTests.util import get_userid
from filelock import FileLock


@pytest.mark.parametrize(
Expand Down Expand Up @@ -320,7 +317,7 @@ def test_with_statement(self):
with XTCReader(XTC) as trj:
N = trj.n_frames
frames = [ts.frame for ts in trj]
except:
except Exception:
raise AssertionError("with_statement not working for XTCReader")
assert_equal(
N,
Expand Down Expand Up @@ -1047,16 +1044,25 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory):
assert_equal(os.path.exists(XDR.offsets_filename(filename)), False)
# check the lock file is not created as well.
assert_equal(
os.path.exists(XDR.offsets_filename(filename, ending=".lock")),
os.path.exists(XDR.offsets_filename(filename, ending="lock")),
False,
)

@pytest.mark.skipif(
sys.platform.startswith("win"),
reason="The lock file only exists when it's locked in windows",
)
def test_offset_lock_created(self, traj):
assert os.path.exists(XDR.offsets_filename(traj, ending="lock"))
def test_offset_lock_created(self):
lock_file_path = XDR.offsets_filename(self.filename, ending="lock")

with FileLock(lock_file_path) as lock:
# Lock acquired in context manager, so lock file should exist
assert lock.is_locked
assert os.path.exists(lock_file_path)

# Explicitly release lock, file should be deleted on UNIX
lock.release()
assert not lock.is_locked
if not sys.platform.startswith("win"):
# As of filelock>=3.21.0, filelock explicitly deletes lockfile
# upon release on UNIX. filelock does not do that on windows.
assert not os.path.exists(lock_file_path)


class TestXTCReader_offsets(_GromacsReader_offsets):
Expand Down
Loading