Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
19691360
Kaydet (Commit)
19691360
authored
Nis 29, 2003
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for urlretrieve. Also made sure urlopen tests cleaned up properly after themselves.
üst
6e887bb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
8 deletions
+48
-8
test_urllib.py
Lib/test/test_urllib.py
+48
-8
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
19691360
...
...
@@ -35,6 +35,7 @@ class urlopen_FileTests(unittest.TestCase):
def
tearDown
(
self
):
"""Shut down the open object"""
self
.
returned_obj
.
close
()
os
.
remove
(
test_support
.
TESTFN
)
def
test_interface
(
self
):
# Make sure object returned by urlopen() has the specified methods
...
...
@@ -87,16 +88,54 @@ class urlopen_FileTests(unittest.TestCase):
for
line
in
self
.
returned_obj
.
__iter__
():
self
.
assertEqual
(
line
,
self
.
text
)
class
urlretrieve_Tests
(
unittest
.
TestCase
):
class
urlretrieve_
File
Tests
(
unittest
.
TestCase
):
"""Test urllib.urlretrieve() on local files"""
pass
class
_urlopener_Tests
(
unittest
.
TestCase
):
"""Make sure urlopen() and urlretrieve() use the class assigned to
_urlopener"""
#XXX: Maybe create a custom class here that takes in a list and modifies
# it to signal that it was called?
pass
def
setUp
(
self
):
# Create a temporary file.
self
.
text
=
'testing urllib.urlretrieve'
FILE
=
file
(
test_support
.
TESTFN
,
'wb'
)
FILE
.
write
(
self
.
text
)
FILE
.
close
()
def
tearDown
(
self
):
# Delete the temporary file.
os
.
remove
(
test_support
.
TESTFN
)
def
test_basic
(
self
):
# Make sure that a local file just gets its own location returned and
# a headers value is returned.
result
=
urllib
.
urlretrieve
(
"file:
%
s"
%
test_support
.
TESTFN
)
self
.
assertEqual
(
result
[
0
],
test_support
.
TESTFN
)
self
.
assert_
(
isinstance
(
result
[
1
],
mimetools
.
Message
),
"did not get a mimetools.Message instance as second "
"returned value"
)
def
test_copy
(
self
):
# Test that setting the filename argument works.
second_temp
=
"
%
s.2"
%
test_support
.
TESTFN
result
=
urllib
.
urlretrieve
(
"file:
%
s"
%
test_support
.
TESTFN
,
second_temp
)
self
.
assertEqual
(
second_temp
,
result
[
0
])
self
.
assert_
(
os
.
path
.
exists
(
second_temp
),
"copy of the file was not "
"made"
)
FILE
=
file
(
second_temp
,
'rb'
)
try
:
text
=
FILE
.
read
()
finally
:
FILE
.
close
()
self
.
assertEqual
(
self
.
text
,
text
)
def
test_reporthook
(
self
):
# Make sure that the reporthook works.
def
hooktester
(
count
,
block_size
,
total_size
,
count_holder
=
[
0
]):
self
.
assert_
(
isinstance
(
count
,
int
))
self
.
assert_
(
isinstance
(
block_size
,
int
))
self
.
assert_
(
isinstance
(
total_size
,
int
))
self
.
assertEqual
(
count
,
count_holder
[
0
])
count_holder
[
0
]
=
count_holder
[
0
]
+
1
second_temp
=
"
%
s.2"
%
test_support
.
TESTFN
urllib
.
urlretrieve
(
test_support
.
TESTFN
,
second_temp
,
hooktester
)
os
.
remove
(
second_temp
)
class
QuotingTests
(
unittest
.
TestCase
):
"""Tests for urllib.quote() and urllib.quote_plus()
...
...
@@ -371,6 +410,7 @@ class Pathname_Tests(unittest.TestCase):
def
test_main
():
test_suite
=
unittest
.
TestSuite
()
test_suite
.
addTest
(
unittest
.
makeSuite
(
urlopen_FileTests
))
test_suite
.
addTest
(
unittest
.
makeSuite
(
urlretrieve_FileTests
))
test_suite
.
addTest
(
unittest
.
makeSuite
(
QuotingTests
))
test_suite
.
addTest
(
unittest
.
makeSuite
(
UnquotingTests
))
test_suite
.
addTest
(
unittest
.
makeSuite
(
urlencode_Tests
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment