File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
src/ansys/dynamicreporting/core/utils Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 30
30
# Modules
31
31
# ------------------------------------------------
32
32
import functools
33
+ import getpass
33
34
import logging
34
35
import os
35
36
import threading
@@ -473,7 +474,7 @@ def nexus_file_lock(filename: str) -> BaseFileLock:
473
474
# We will consider two pathnames:
474
475
# 1) the original pathname
475
476
# 2) replace the original filename directory with tempfile.gettempdir()
476
- base_filename = os .path .basename (filename ) + "." + os . getlogin ()
477
+ base_filename = os .path .basename (filename ) + "." + getpass . getuser ()
477
478
lcl_filename = os .path .join (tempfile .gettempdir (), base_filename )
478
479
479
480
# if we are on Linux and the target filename is on an NFS drive
Original file line number Diff line number Diff line change @@ -111,12 +111,11 @@ def test_soft(request) -> None:
111
111
def test_nexus_filelock (request ) -> None :
112
112
test_path = join (request .fspath .dirname , "test_data" )
113
113
tmp_file = join (test_path , "n_lock.txt" )
114
- try :
115
- success = type (fl .nexus_file_lock (filename = tmp_file )) is fl .FileLock
116
- except OSError : # Error due to not being able to get os.getlogin() on the machine
117
- success = True
118
- else :
119
- success = False
120
- if "win" in platform .system ().lower ():
121
- success = True
122
- assert success
114
+
115
+ lock = fl .nexus_file_lock (filename = tmp_file )
116
+
117
+ # Debug info
118
+ print ("Resolved lock type:" , type (lock ))
119
+ print ("Expected FileLock type:" , fl .FileLock )
120
+
121
+ assert isinstance (lock , fl .FileLock )
You can’t perform that action at this time.
0 commit comments