2024-10-16 15:13:17 +02:00
|
|
|
---
|
2024-10-17 13:08:35 +02:00
|
|
|
Lib/test/test_urllib2.py | 9 +++++++++
|
|
|
|
1 file changed, 9 insertions(+)
|
2024-10-16 15:13:17 +02:00
|
|
|
|
|
|
|
--- a/Lib/test/test_urllib2.py
|
|
|
|
+++ b/Lib/test/test_urllib2.py
|
2024-10-17 13:08:35 +02:00
|
|
|
@@ -1,3 +1,4 @@
|
|
|
|
+import logging
|
|
|
|
import unittest
|
|
|
|
from test import support
|
|
|
|
from test.support import os_helper
|
|
|
|
@@ -29,6 +30,10 @@ import http.client
|
|
|
|
|
|
|
|
support.requires_working_socket(module=True)
|
|
|
|
|
|
|
|
+logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
|
|
|
|
+ level=logging.DEBUG)
|
|
|
|
+log = logging.getLogger()
|
|
|
|
+
|
|
|
|
# XXX
|
|
|
|
# Request
|
|
|
|
# CacheFTPHandler (hard to write)
|
|
|
|
@@ -731,6 +736,9 @@ def sanepathname2url(path):
|
|
|
|
|
|
|
|
class HandlerTests(unittest.TestCase):
|
|
|
|
|
|
|
|
+ def setUp(self):
|
|
|
|
+ log.debug('Is network available: {}'.format(support.is_resource_enabled('network')))
|
|
|
|
+
|
|
|
|
def test_ftp(self):
|
|
|
|
class MockFTPWrapper:
|
|
|
|
def __init__(self, data):
|
|
|
|
@@ -794,6 +802,7 @@ class HandlerTests(unittest.TestCase):
|
2024-10-17 07:35:58 +02:00
|
|
|
self.assertEqual(headers.get("Content-type"), mimetype)
|
2024-10-16 15:13:17 +02:00
|
|
|
self.assertEqual(int(headers["Content-length"]), len(data))
|
|
|
|
|
2024-10-17 12:31:44 +02:00
|
|
|
+ @support.requires_resource('network')
|
2024-10-16 15:13:17 +02:00
|
|
|
def test_ftp_error(self):
|
|
|
|
class ErrorFTPHandler(urllib.request.FTPHandler):
|
|
|
|
def __init__(self, exception):
|