From 0a3cfc53c106c9473f438ec34612f52b0861dc05 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Wed, 18 Feb 2026 13:09:13 -0500 Subject: [PATCH 1/9] remove xdr test for checking lock file --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 2a2f236924e..c245420a60d 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -1051,13 +1051,6 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): 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")) - class TestXTCReader_offsets(_GromacsReader_offsets): __test__ = True From b530d51550f02841febe169e4b22d9e1f9a1af89 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Wed, 18 Feb 2026 15:17:46 -0500 Subject: [PATCH 2/9] replacement test for test_offset_lock_created --- .../MDAnalysisTests/coordinates/test_xdr.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index c245420a60d..7ad999755d6 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -25,10 +25,7 @@ import re import os -import sys import shutil -import subprocess -import time from pathlib import Path import numpy as np @@ -59,7 +56,6 @@ ) 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 @@ -320,7 +316,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, @@ -1051,6 +1047,19 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): False, ) + 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 + lock.release() + assert not lock.is_locked + assert not os.path.exists(lock_file_path) + class TestXTCReader_offsets(_GromacsReader_offsets): __test__ = True From 78e0cee2cf9746e516ea48cbd22f312cf85026d4 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Wed, 18 Feb 2026 15:24:08 -0500 Subject: [PATCH 3/9] add myself to AUTHORS and CHANGELOG --- package/AUTHORS | 1 + package/CHANGELOG | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package/AUTHORS b/package/AUTHORS index 1d7e1646794..ce64724bae6 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -271,6 +271,7 @@ Chronological list of authors - Mohammad Ayaan - Khushi Phougat - Kushagar Garg + - Jeremy M. G. Leung External code ------------- diff --git a/package/CHANGELOG b/package/CHANGELOG index 7ac8f41b184..17a0059f618 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -15,7 +15,7 @@ The rules for this file: ------------------------------------------------------------------------------- ??/??/?? IAlibay, orbeckst, marinegor, tylerjereddy, ljwoods2, marinegor, - spyke7, talagayev, tanii1125, BradyAJohnston + spyke7, talagayev, tanii1125, BradyAJohnston, jeremyleung521 * 2.11.0 @@ -35,6 +35,7 @@ Fixes to version 5.1.0 (Issue #5145, PR #5146) * Fixes incorrect assignment of secondary structure to proline residues in DSSP by porting upstream PyDSSP 0.9.1 fix (Issue #4913) + * Drop/Replace lock file test in test_xdr (Issue #5236, PR #5237) Enhancements * Adds support for parsing `.tpr` files produced by GROMACS 2026.0 From 7ce934413b17c2db6d4287cdcb6668fa972f1eec Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Wed, 18 Feb 2026 16:39:18 -0500 Subject: [PATCH 4/9] Windows does not immediately remove the lock file after release --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 7ad999755d6..b2d584d41c9 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -26,6 +26,7 @@ import re import os import shutil +import sys from pathlib import Path import numpy as np @@ -1047,6 +1048,7 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): False, ) + def test_offset_lock_created(self): lock_file_path = XDR.offsets_filename(self.filename, ending="lock") @@ -1055,10 +1057,11 @@ def test_offset_lock_created(self): assert lock.is_locked assert os.path.exists(lock_file_path) - # Explicitly release lock, file should be deleted + # Explicitly release lock, file should be deleted on UNIX lock.release() assert not lock.is_locked - assert not os.path.exists(lock_file_path) + if not sys.platform.startswith("win"): + assert not os.path.exists(lock_file_path) class TestXTCReader_offsets(_GromacsReader_offsets): From a1e6639f0a67146e46762d16c7113f88f280d701 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Wed, 18 Feb 2026 16:44:10 -0500 Subject: [PATCH 5/9] black lint --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index b2d584d41c9..88cff2d840c 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -1048,7 +1048,6 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): False, ) - def test_offset_lock_created(self): lock_file_path = XDR.offsets_filename(self.filename, ending="lock") From 4b6019cd97d910eaa0635944bc1ad554ae6ed3f9 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Thu, 19 Feb 2026 11:38:41 -0500 Subject: [PATCH 6/9] add comments on why we don't test on windows --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 88cff2d840c..09cadd7797e 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -1060,6 +1060,8 @@ def test_offset_lock_created(self): 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) From b0896a67847153c504cbfb9ee47c3e5f4fd24929 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Thu, 19 Feb 2026 12:35:15 -0500 Subject: [PATCH 7/9] fix typo in test_persistent_offsets_readonly, causing check to always pass --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 09cadd7797e..fb96e81c233 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -1044,7 +1044,7 @@ 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, ) From e0f0c435262a1cc9ce2d1a32152a24bbf63dd664 Mon Sep 17 00:00:00 2001 From: "Jeremy M. G. Leung" Date: Tue, 24 Feb 2026 17:01:32 -0500 Subject: [PATCH 8/9] move filelock import up --- testsuite/MDAnalysisTests/coordinates/test_xdr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index fb96e81c233..c23fbf47da4 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -27,6 +27,7 @@ import os import shutil import sys +from filelock import FileLock from pathlib import Path import numpy as np @@ -59,7 +60,6 @@ import MDAnalysis as mda from MDAnalysis.coordinates import XDR from MDAnalysisTests.util import get_userid -from filelock import FileLock @pytest.mark.parametrize( From 00d3d558049114c92e028e8971dd1f9ed2f68551 Mon Sep 17 00:00:00 2001 From: Yuxuan Zhuang Date: Wed, 25 Feb 2026 11:15:44 -0800 Subject: [PATCH 9/9] newest entry first. --- package/CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index 90c96ac8f2e..010bae54c1b 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -20,6 +20,7 @@ The rules for this file: * 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 @@ -35,7 +36,6 @@ Fixes to version 5.1.0 (Issue #5145, PR #5146) * Fixes incorrect assignment of secondary structure to proline residues in DSSP by porting upstream PyDSSP 0.9.1 fix (Issue #4913) - * Drop/Replace lock file test in test_xdr (Issue #5236, PR #5237) Enhancements * Improved performance of `AtomGroup.wrap()` with compounds (PR #5220)