MCPcopy Index your code
hub / github.com/mne-tools/mne-python / _TempDir

Class _TempDir

mne/utils/_testing.py:36–56  ·  view source on GitHub ↗

Create and auto-destroy temp dir. This is designed to be used with testing modules. Instances should be defined inside test functions. Instances defined at module level can not guarantee proper destruction of the temporary directory. When used at module level, the current use of th

Source from the content-addressed store, hash-verified

34
35
36class _TempDir(str):
37 """Create and auto-destroy temp dir.
38
39 This is designed to be used with testing modules. Instances should be
40 defined inside test functions. Instances defined at module level can not
41 guarantee proper destruction of the temporary directory.
42
43 When used at module level, the current use of the __del__() method for
44 cleanup can fail because the rmtree function may be cleaned up before this
45 object (an alternative could be using the atexit module instead).
46 """
47
48 def __new__(self): # noqa: D105
49 new = str.__new__(self, tempfile.mkdtemp(prefix="tmp_mne_tempdir_"))
50 return new
51
52 def __init__(self):
53 self._path = self.__str__()
54
55 def __del__(self): # noqa: D105
56 rmtree(self._path, ignore_errors=True)
57
58
59def requires_mne(func):

Callers 9

protect_configFunction · 0.90
test_tempdirFunction · 0.90
_test_raw_readerFunction · 0.90
make_watershed_bemFunction · 0.85
convert_flash_mrisFunction · 0.85
make_flash_bemFunction · 0.85
_decimate_surface_sphereFunction · 0.85

Calls

no outgoing calls

Tested by 3

protect_configFunction · 0.72
test_tempdirFunction · 0.72
_test_raw_readerFunction · 0.72