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

Method test_file_notexists

Lib/test/test_urllib.py:486–501  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

484 self.assertTrue(e.exception.reason)
485
486 def test_file_notexists(self):
487 fd, tmp_file = tempfile.mkstemp()
488 tmp_file_canon_url = urllib.request.pathname2url(tmp_file, add_scheme=True)
489 parsed = urllib.parse.urlsplit(tmp_file_canon_url)
490 tmp_fileurl = parsed._replace(netloc='localhost').geturl()
491 try:
492 self.assertTrue(os.path.exists(tmp_file))
493 with urllib.request.urlopen(tmp_fileurl) as fobj:
494 self.assertTrue(fobj)
495 self.assertEqual(fobj.url, tmp_file_canon_url)
496 finally:
497 os.close(fd)
498 os.unlink(tmp_file)
499 self.assertFalse(os.path.exists(tmp_file))
500 with self.assertRaises(urllib.error.URLError):
501 urllib.request.urlopen(tmp_fileurl)
502
503 def test_ftp_nohost(self):
504 test_ftp_url = 'ftp:///path'

Callers

nothing calls this directly

Calls 10

assertTrueMethod · 0.80
assertFalseMethod · 0.80
geturlMethod · 0.45
_replaceMethod · 0.45
existsMethod · 0.45
urlopenMethod · 0.45
assertEqualMethod · 0.45
closeMethod · 0.45
unlinkMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected