(self)
| 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' |
nothing calls this directly
no test coverage detected