summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllibnet.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-08-01 00:06:49 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-08-01 00:06:49 (GMT)
commitbdbddf8a82efd0e67f4006af91ce65bec2bf0a60 (patch)
treeb57b0cb69a03af535aba7a0039bf659622725651 /Lib/test/test_urllibnet.py
parente19cadb427b6910930b50584bd9066ab5b198300 (diff)
downloadcpython-bdbddf8a82efd0e67f4006af91ce65bec2bf0a60.zip
cpython-bdbddf8a82efd0e67f4006af91ce65bec2bf0a60.tar.gz
cpython-bdbddf8a82efd0e67f4006af91ce65bec2bf0a60.tar.bz2
#2491: os.fdopen() is now almost an alias to the builtin open(), and accepts the same parameters.
It just checks that the first argument is a file descriptor.
Diffstat (limited to 'Lib/test/test_urllibnet.py')
-rw-r--r--Lib/test/test_urllibnet.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index c8166c4..695541c 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -113,18 +113,14 @@ class urlopenNetworkTests(unittest.TestCase):
self.assertEqual(code, 404)
def test_fileno(self):
- if (sys.platform in ('win32',) or
- not hasattr(os, 'fdopen')):
+ if sys.platform in ('win32',):
# On Windows, socket handles are not file descriptors; this
# test can't pass on Windows.
return
# Make sure fd returned by fileno is valid.
open_url = self.urlopen("http://www.python.org/")
fd = open_url.fileno()
- # XXX(nnorwitz): There is currently no way to pass errors, encoding,
- # etc to fdopen. :-(
- FILE = os.fdopen(fd)
- FILE._errors = 'ignore'
+ FILE = os.fdopen(fd, encoding='utf-8')
try:
self.assert_(FILE.read(), "reading from file created using fd "
"returned by fileno failed")
@@ -156,7 +152,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
file_location,info = self.urlretrieve("http://www.python.org/")
self.assert_(os.path.exists(file_location), "file location returned by"
" urlretrieve is not a valid path")
- FILE = open(file_location, errors='ignore')
+ FILE = open(file_location, encoding='utf-8')
try:
self.assert_(FILE.read(), "reading from the file location returned"
" by urlretrieve failed")
@@ -170,7 +166,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
support.TESTFN)
self.assertEqual(file_location, support.TESTFN)
self.assert_(os.path.exists(file_location))
- FILE = open(file_location, errors='ignore')
+ FILE = open(file_location, encoding='utf-8')
try:
self.assert_(FILE.read(), "reading from temporary file failed")
finally: