Skip to content

change XTC/TRR tests for lock file presence#5423

Open
orbeckst wants to merge 3 commits into
developfrom
fix-filelocktest-5382
Open

change XTC/TRR tests for lock file presence#5423
orbeckst wants to merge 3 commits into
developfrom
fix-filelocktest-5382

Conversation

@orbeckst

@orbeckst orbeckst commented Jul 11, 2026

Copy link
Copy Markdown
Member

Fixes #5382

Changes made in this Pull Request:

  • filelock >= 3.29.5 will now never remove the lockfile (avoids a race condition on POSIX): changed the correspond test (xfail for older versions of filelock)
  • filelock also apparently changed behavior on Windows: it used to leave the lock file around but now it seems to be removing it (based on the windows runners): changed the test to account for this new behavior
  • updated doc string XDRBaseReader._load_offsets to indicate that we use filelock
  • added more docs to XDR page (more details on offsets)
  • add filelock docs to intersphinx mapping

LLM / AI generated code disclosure

LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)
  • LLM/AI disclosure was updated.

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.

- fix #5382
- filelock >= 3.29.5 will now never remove the lockfile (avoids a race condition on POSIX):
  changed the correspond test (xfail for older versions of fielock)
- updated doc string XDRBaseReader._load_offsets to indicate that we use filelock
- added more docs to XDR page (more details on offsets)
- add filelock docs to intersphinx mapping
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.84%. Comparing base (32b7808) to head (b644345).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5423      +/-   ##
===========================================
- Coverage    93.85%   93.84%   -0.01%     
===========================================
  Files          182      182              
  Lines        22509    22510       +1     
  Branches      3202     3202              
===========================================
  Hits         21125    21125              
- Misses         922      923       +1     
  Partials       462      462              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@orbeckst orbeckst force-pushed the fix-filelocktest-5382 branch from 42127e8 to 7c7724e Compare July 11, 2026 06:02
@orbeckst

Copy link
Copy Markdown
Member Author

Not sure what the linter is complaining about. Pre-commit (with black 24.10) was happy.

The feedback from linters/black is close to useless to me as it just says "2 files would be reformatted, 218 files would be left unchanged." without telling me which one. (And please don't make me read the list of 200 files that it touched to find the one that does not say "already well formatted, good job."...).

@orbeckst orbeckst changed the title change XTC/TRR tests for now persistent lock file change XTC/TRR tests for lock file presence Jul 11, 2026
@orbeckst

Copy link
Copy Markdown
Member Author

It looks as if on Win, the lock file is being removed (?!). https://dev.azure.com/mdanalysis/mdanalysis/_build/results?buildId=9343&view=logs&j=dc60759d-7bf7-580f-541c-8b624e38610f&t=c864e5cd-d904-5b0e-978b-27ea9778a5fc&l=843

_______________ TestXTCReader_offsets.test_offset_lock_created ________________
[gw1] win32 -- Python 3.11.9 C:\hostedtoolcache\windows\Python\3.11.9\x64\python.exe

self = <MDAnalysisTests.coordinates.test_xdr.TestXTCReader_offsets object at 0x00000214C33F2550>

    @pytest.mark.xfail(
        Version(filelock.__version__) < Version("3.29.5"),
        reason="unsecure version of filelock",
    )
    def test_offset_lock_created(self):
        lock_file_path = XDR.offsets_filename(self.filename, ending="lock")
    
        with filelock.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)
    
        # released lock
        assert not lock.is_locked
    
        # for filelock>=3.21.0,<3.29.5, the lockfile was deleted on POSIX, but
        # this can lead to race conditions. Secure versions of filelock keep the
        # lockfile:
>       assert os.path.exists(lock_file_path)
E       AssertionError: assert False
E        +  where False = <function exists at 0x00000214A835C220>('D:/a/1/s/testsuite/MDAnalysisTests/data\\.adk_oplsaa.xtc_offsets.lock')
E        +    where <function exists at 0x00000214A835C220> = <module 'ntpath' (frozen)>.exists
E        +      where <module 'ntpath' (frozen)> = os.path

D:\a\1\s\testsuite\MDAnalysisTests\coordinates\test_xdr.py:1070: AssertionError

@orbeckst orbeckst requested review from IAlibay and yuxuanzhuang July 11, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestXTCReader_offsets.test_offset_lock_created and TestTRRReader_offsets.test_offset_lock_created always fail

1 participant