Utility functions for python tests that download their own (DICOM or other) data from the web

I’m writing a few new automated python tests for extensions, and realized that I keep adding the same functions in my tests unchanged. These functions

  • Download data, unzip to temp folder, verify total number of unzipped files
  • Import data to temporary DICOM database from the above folder
  • Select loadables, verify plugin selection, and load loadables

Do you think it would make sense to add these in the ScriptedLoadableModuleTest class?


It could be added to the slicer.testing module.

Ideally, it could be used as a function or a context manager.

something like:

with TemporaryDICOMData(url="http://path/to/file.zip") as loader:
  assert loader.selected_plugins == ["plugin1", ...]

Thanks! I’ll try to do it like this then. I’ll be back with a PR.

1 Like

I think I’ll add this to https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/DICOMLib/DICOMUtils.py instead. There is a feature very similar to the proposed one here already, and it would be confusing to separate them.


I issued the pull request: https://github.com/Slicer/Slicer/pull/835

I tested it with SubjectHierarchyGenericSelfTest and GelDosimetryAnalysis, both work well.

1 Like