MCPcopy
hub / github.com/mne-tools/mne-python / ArgvSetter

Class ArgvSetter

mne/utils/_testing.py:120–140  ·  view source on GitHub ↗

Temporarily set sys.argv.

Source from the content-addressed store, hash-verified

118
119
120class ArgvSetter:
121 """Temporarily set sys.argv."""
122
123 def __init__(self, args=(), disable_stdout=True, disable_stderr=True):
124 self.argv = list(("python",) + args)
125 self.stdout = ClosingStringIO() if disable_stdout else sys.stdout
126 self.stderr = ClosingStringIO() if disable_stderr else sys.stderr
127
128 def __enter__(self): # noqa: D105
129 self.orig_argv = sys.argv
130 sys.argv = self.argv
131 self.orig_stdout = sys.stdout
132 sys.stdout = self.stdout
133 self.orig_stderr = sys.stderr
134 sys.stderr = self.stderr
135 return self
136
137 def __exit__(self, *args): # noqa: D105
138 sys.argv = self.orig_argv
139 sys.stdout = self.orig_stdout
140 sys.stderr = self.orig_stderr
141
142
143def has_mne_c():

Callers 15

generate_commands_rstFunction · 0.90
check_usageFunction · 0.90
test_browse_rawFunction · 0.90
test_whatFunction · 0.90
test_show_fiffFunction · 0.90
test_clean_eog_ecgFunction · 0.90
test_compute_proj_exgFunction · 0.90
test_make_scalp_surfacesFunction · 0.90
test_reportFunction · 0.90
test_watershed_bemFunction · 0.90
test_flash_bemFunction · 0.90
test_setup_source_spaceFunction · 0.90

Calls

no outgoing calls

Tested by 15

check_usageFunction · 0.72
test_browse_rawFunction · 0.72
test_whatFunction · 0.72
test_show_fiffFunction · 0.72
test_clean_eog_ecgFunction · 0.72
test_compute_proj_exgFunction · 0.72
test_make_scalp_surfacesFunction · 0.72
test_reportFunction · 0.72
test_watershed_bemFunction · 0.72
test_flash_bemFunction · 0.72
test_setup_source_spaceFunction · 0.72
test_setup_forward_modelFunction · 0.72