MCPcopy Index your code
hub / github.com/python/cpython / test_security_only_once

Method test_security_only_once

Lib/test/test_netrc.py:318–333  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

316 @unittest.skipUnless(hasattr(os, 'getuid'), "os.getuid is required")
317 @os_helper.skip_unless_working_chmod
318 def test_security_only_once(self):
319 # Make sure security check is only run once per parse when multiple
320 # entries are found.
321 with patch.object(netrc.netrc, "_security_check") as mock:
322 with os_helper.temp_dir() as tmp_dir:
323 netrc_path = Path(tmp_dir) / '.netrc'
324 netrc_path.write_text("""\
325 machine foo.domain.com login bar password pass
326 machine bar.domain.com login foo password pass
327 """)
328 netrc_path.chmod(0o600)
329 with os_helper.EnvironmentVarGuard() as environ:
330 environ.set('HOME', tmp_dir)
331 netrc.netrc()
332
333 mock.assert_called_once()
334
335
336if __name__ == "__main__":

Callers

nothing calls this directly

Calls 6

PathClass · 0.90
temp_dirMethod · 0.80
assert_called_onceMethod · 0.80
write_textMethod · 0.45
chmodMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected