diff --git a/package/MDAnalysis/coordinates/XDR.py b/package/MDAnalysis/coordinates/XDR.py index 48d0ae6da6..a573f67708 100644 --- a/package/MDAnalysis/coordinates/XDR.py +++ b/package/MDAnalysis/coordinates/XDR.py @@ -37,7 +37,6 @@ import errno import numpy as np import os -from pathlib import Path from os.path import getctime, getsize, isfile, split, join import warnings @@ -200,7 +199,6 @@ def _load_offsets(self): # check if the location of the lock is writable. try: - Path(lock_name).parent.mkdir(parents=True, exist_ok=True) with FileLock(lock_name) as filelock: pass except OSError as e: diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index e6caeebb07..084c2c23bb 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -22,7 +22,7 @@ # import pytest from unittest.mock import patch - +from time import time import re import os import shutil @@ -897,13 +897,22 @@ def test_persistent_offsets_readonly(self, tmpdir): if os.name == 'nt': # Windows platform: deny write access using `icacls` subprocess.run( - f"icacls {tmpdir} /deny Users:W", + f"icacls {tmpdir} /deny Users:W /T", shell=True, check=True # Raises an error if the command fails ) + # print the permissions to check if they are set correctly + subprocess.run( + f'icacls {tmpdir}', + shell=True, + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) else: # Non-Windows platforms: use chmod for read and execute only os.chmod(str(tmpdir), 0o555) + time.sleep(1) # wait for permissions to be set filename = str(tmpdir.join(os.path.basename(self.filename))) # try to write a offsets file