heudiconv
heudiconv copied to clipboard
FIX: Lingering temporary directories
This is a spin-off of #466 and a continuation of #485
After first confirming the problem with a failing test, this PR:
- Removes custom temporary directory object from various function signatures
- Replaces temporary directory creation with context managers (where possible)
- Simplifies and moves
TempDirsobject into a dedicated module
the fail
=================================== FAILURES ===================================
____________________________ test_smoke_convertall _____________________________
heudiconv/tests/test_heuristics.py:42: in test_smoke_convertall
assert not list(Path(tempfile.gettempdir()).glob('heudiconv*'))
E AssertionError: assert not [PosixPath('/tmp/heudiconvDCM42wzdx58'), PosixPath('/tmp/heudiconvDCMqb920gwc'), PosixPath('/tmp/heudiconvDCM3w5cw9bq')]
E + where [PosixPath('/tmp/heudiconvDCM42wzdx58'), PosixPath('/tmp/heudiconvDCMqb920gwc'), PosixPath('/tmp/heudiconvDCM3w5cw9bq')] = list(<generator object Path.glob at 0x7fa918d4df20>)
E + where <generator object Path.glob at 0x7fa918d4df20> = <bound method Path.glob of PosixPath('/tmp')>('heudiconv*')
E + where <bound method Path.glob of PosixPath('/tmp')> = PosixPath('/tmp').glob
E + where PosixPath('/tmp') = Path('/tmp')
E + where '/tmp' = <function gettempdir at 0x7fa924f2e040>()
E + where <function gettempdir at 0x7fa924f2e040> = tempfile.gettempdir
------------------------------ Captured log call -------------------------------
main.py 262 INFO Running heudiconv version 0.9.0 latest 0.9.0
main.py 262 INFO Running heudiconv version 0.9.0 latest 0.9.0
main.py 291 INFO Need to process 0 study sessions
=============== 1 failed, 55 passed, 4 skipped in 203.21 seconds ===============
The command "coverage run `which py.test` -s -v heudiconv" exited with 1.```
Codecov Report
Merging #512 (6e95e14) into master (f44c099) will increase coverage by
0.05%. The diff coverage is89.87%.
:exclamation: Current head 6e95e14 differs from pull request most recent head f78fdef. Consider uploading reports for the commit f78fdef to get more accurate results
@@ Coverage Diff @@
## master #512 +/- ##
==========================================
+ Coverage 77.28% 77.34% +0.05%
==========================================
Files 41 42 +1
Lines 3108 3098 -10
==========================================
- Hits 2402 2396 -6
+ Misses 706 702 -4
| Impacted Files | Coverage Δ | |
|---|---|---|
| heudiconv/utils.py | 90.56% <ø> (+0.36%) |
:arrow_up: |
| heudiconv/dicoms.py | 82.11% <82.05%> (ø) |
|
| heudiconv/convert.py | 86.98% <88.88%> (-0.16%) |
:arrow_down: |
| heudiconv/_tmpdirs.py | 100.00% <100.00%> (ø) |
|
| heudiconv/main.py | 77.09% <100.00%> (+0.53%) |
:arrow_up: |
| heudiconv/parser.py | 92.63% <100.00%> (-0.08%) |
:arrow_down: |
| heudiconv/tests/test_heuristics.py | 100.00% <100.00%> (ø) |
|
| heudiconv/tests/test_tarballs.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update f44c099...f78fdef. Read the comment docs.