(self)
| 799 | |
| 800 | @support.requires_resource("network") |
| 801 | def test_ftp_error(self): |
| 802 | class ErrorFTPHandler(urllib.request.FTPHandler): |
| 803 | def __init__(self, exception): |
| 804 | self._exception = exception |
| 805 | |
| 806 | def connect_ftp(self, user, passwd, host, port, dirs, |
| 807 | timeout=socket._GLOBAL_DEFAULT_TIMEOUT): |
| 808 | raise self._exception |
| 809 | |
| 810 | exception = ftplib.error_perm( |
| 811 | "500 OOPS: cannot change directory:/nonexistent") |
| 812 | h = ErrorFTPHandler(exception) |
| 813 | urlopen = urllib.request.build_opener(h).open |
| 814 | try: |
| 815 | urlopen("ftp://www.pythontest.net/") |
| 816 | except urllib.error.URLError as raised: |
| 817 | self.assertEqual(raised.reason, |
| 818 | f"ftp error: {exception.args[0]}") |
| 819 | else: |
| 820 | self.fail("Did not raise ftplib exception") |
| 821 | |
| 822 | def test_file(self): |
| 823 | import email.utils |
nothing calls this directly
no test coverage detected