sot / mica

Microscope on Chandra aspect
https://sot.github.io/mica
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

in tests_acq/guide: close temp file before unlinking it #294

Closed javierggt closed 6 months ago

javierggt commented 6 months ago

Description

In tests_acq/guide: close temp file before unlinking it.

From the docs:

mkstemp() returns a tuple containing an OS-level handle to an open file (as would be returned by os.open())

Since the file is open, it should be close before unlinking. Otherwise, one gets this error on windows:

        fh, fn = tempfile.mkstemp(suffix='.h5')
>       os.unlink(fn)
E       PermissionError: [WinError 32] The process cannot access the file because it is being used by another process

I know we would not use this on windows most probably, but still...

Interface impacts

Testing

Unit tests

Independent check of unit tests by [REVIEWER NAME]

Functional tests

After this PR, the test do not fail at this point in Windows. They fail later because I test on a VM, and the symbolic links in mica/archive/obspar are not supported in the VM