MCPcopy
hub / github.com/numpy/numpy / test_sandboxing

Method test_sandboxing

numpy/lib/tests/test__datasource.py:219–232  ·  view source on GitHub ↗
(self, tmp_path)

Source from the content-addressed store, hash-verified

217 assert_(invalidfile != ds.abspath(tmpfile))
218
219 def test_sandboxing(self, tmp_path):
220 ds = datasource.DataSource(tmp_path)
221 tmpfile = valid_textfile(tmp_path)
222 tmpfilename = os.path.split(tmpfile)[-1]
223
224 path = lambda x: os.path.abspath(ds.abspath(x))
225
226 assert_(path(valid_httpurl()).startswith(str(tmp_path)))
227 assert_(path(invalid_httpurl()).startswith(str(tmp_path)))
228 assert_(path(tmpfile).startswith(str(tmp_path)))
229 assert_(path(tmpfilename).startswith(str(tmp_path)))
230 for fn in malicious_files:
231 assert_(path(http_path + fn).startswith(str(tmp_path)))
232 assert_(path(fn).startswith(str(tmp_path)))
233
234 def test_windows_os_sep(self, tmp_path):
235 orig_os_sep = os.sep

Callers 1

test_windows_os_sepMethod · 0.95

Calls 7

abspathMethod · 0.95
assert_Function · 0.90
valid_textfileFunction · 0.85
valid_httpurlFunction · 0.85
invalid_httpurlFunction · 0.85
splitMethod · 0.80
startswithMethod · 0.80

Tested by

no test coverage detected