CLIMADA-project / climada_petals

See https://github.com/CLIMADA-project/climada_python first
GNU General Public License v3.0
22 stars 13 forks source link

test_rf_glofas fails on Windows #127

Open emanuel-schmid opened 1 month ago

emanuel-schmid commented 1 month ago

Apparently temporary directories and, possibly, Mock behave differently on Windows.

Running

pytest climada_petals\hazard\rf_glofas\test

eventually yields the following output:

...
========================================================================================= short test summary info =========================================================================================== 
FAILED climada_petals\hazard\rf_glofas\test\test_cds_glofas_downloader.py::TestGloFASRequest::test_cleanup_download_dir - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\[user]\\AppData\\Local\\Temp\\tmpcdhavidt\\tmpplz_2o8d'
FAILED climada_petals\hazard\rf_glofas\test\test_river_flood_computation.py::TestRiverFloodInundation::test_flood_depth - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\[user]\\AppData\\Local\\Temp\\tmp8v017e7s\\cache\\240522-092644-nxawxu46\\return-pe...
FAILED climada_petals\hazard\rf_glofas\test\test_transform_ops.py::TestGlofasDownloadOps::test_basic - NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\[user]\\AppData\\Local\\Temp\\tmp1f948t9g\\file-1.nc'
FAILED climada_petals\hazard\rf_glofas\test\test_transform_ops.py::TestGlofasDownloadOps::test_countries_area - TypeError: name must be a str, not a MagicMock
FAILED climada_petals\hazard\rf_glofas\test\test_transform_ops.py::TestGlofasDownloadOps::test_preprocess - TypeError: name must be a str, not a MagicMock
ERROR climada_petals\hazard\rf_glofas\test\test_cds_glofas_downloader.py::TestGloFASRequest::test_cleanup_download_dir - NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\[user]\\AppData\\Local\\Temp\\tmpcdhavidt\\tmpplz_2o8d'
ERROR climada_petals\hazard\rf_glofas\test\test_river_flood_computation.py::TestRiverFloodInundation::test_return_period_resample - NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\[user]\\AppData\\Local\\Temp\\tmp8v017e7s\\cache\\240522-092644-nxawxu46\\return-period-regrid.nc'
============================================================================ 5 failed, 36 passed, 14 warnings, 2 errors in 20.79s ============================================================================ 
peanutfun commented 1 month ago

It might also be that the behavior changed with more recent Python versions. Or are you still on 3.9? This is the second issue related to my model. I'll see when I find time to check both out. But I have to admit that this currently has a low priority for me 🙇

emanuel-schmid commented 1 month ago

Thanks! I'm still on 3.9 on Windows. No worries, it has low priority for me as well.