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
a40681dd
Kaydet (Commit)
a40681dd
authored
6 years ago
tarafından
Stéphane Wirtel
Kaydeden (comit)
Victor Stinner
6 years ago
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36019: Use pythontest.net instead of example.com in network tests (GH-11941)
üst
3208880f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
10 deletions
+22
-10
test.rst
Doc/library/test.rst
+4
-0
__init__.py
Lib/test/support/__init__.py
+4
-0
test_urllib.py
Lib/test/test_urllib.py
+2
-2
test_urllib2net.py
Lib/test/test_urllib2net.py
+6
-6
test_urllibnet.py
Lib/test/test_urllibnet.py
+4
-2
2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
...EWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
+2
-0
No files found.
Doc/library/test.rst
Dosyayı görüntüle @
a40681dd
...
...
@@ -356,6 +356,10 @@ The :mod:`test.support` module defines the following constants:
Check for presence of docstrings.
.. data:: TEST_HTTP_URL
Define the URL of a dedicated HTTP server for the network tests.
The :mod:`test.support` module defines the following functions:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/support/__init__.py
Dosyayı görüntüle @
a40681dd
...
...
@@ -835,6 +835,10 @@ else:
# module name.
TESTFN
=
"{}_{}_tmp"
.
format
(
TESTFN
,
os
.
getpid
())
# Define the URL of a dedicated HTTP server for the network tests.
# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
TEST_HTTP_URL
=
"http://www.pythontest.net"
# FS_NONASCII: non-ASCII character encodable by os.fsencode(),
# or None if there is no such character.
FS_NONASCII
=
None
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_urllib.py
Dosyayı görüntüle @
a40681dd
...
...
@@ -712,7 +712,7 @@ FF
with
self
.
assertRaises
(
urllib
.
error
.
ContentTooShortError
):
try
:
urllib
.
request
.
urlretrieve
(
'http://example.com/'
,
urllib
.
request
.
urlretrieve
(
support
.
TEST_HTTP_URL
,
reporthook
=
_reporthook
)
finally
:
self
.
unfakehttp
()
...
...
@@ -729,7 +729,7 @@ FF
'''
)
with
self
.
assertRaises
(
urllib
.
error
.
ContentTooShortError
):
try
:
urllib
.
request
.
urlretrieve
(
'http://example.com/'
)
urllib
.
request
.
urlretrieve
(
support
.
TEST_HTTP_URL
)
finally
:
self
.
unfakehttp
()
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_urllib2net.py
Dosyayı görüntüle @
a40681dd
...
...
@@ -84,7 +84,7 @@ class CloseSocketTest(unittest.TestCase):
def
test_close
(
self
):
# calling .close() on urllib2's response objects should close the
# underlying socket
url
=
"http://www.example.com/"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
):
response
=
_urlopen_with_retry
(
url
)
sock
=
response
.
fp
...
...
@@ -173,7 +173,7 @@ class OtherNetworkTests(unittest.TestCase):
"http://www.pythontest.net/elsewhere/#frag"
)
def
test_custom_headers
(
self
):
url
=
"http://www.example.com"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
):
opener
=
urllib
.
request
.
build_opener
()
request
=
urllib
.
request
.
Request
(
url
)
...
...
@@ -259,7 +259,7 @@ class OtherNetworkTests(unittest.TestCase):
class
TimeoutTest
(
unittest
.
TestCase
):
def
test_http_basic
(
self
):
self
.
assertIsNone
(
socket
.
getdefaulttimeout
())
url
=
"http://www.example.com"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
,
timeout
=
None
):
u
=
_urlopen_with_retry
(
url
)
self
.
addCleanup
(
u
.
close
)
...
...
@@ -267,7 +267,7 @@ class TimeoutTest(unittest.TestCase):
def
test_http_default_timeout
(
self
):
self
.
assertIsNone
(
socket
.
getdefaulttimeout
())
url
=
"http://www.example.com"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
):
socket
.
setdefaulttimeout
(
60
)
try
:
...
...
@@ -279,7 +279,7 @@ class TimeoutTest(unittest.TestCase):
def
test_http_no_timeout
(
self
):
self
.
assertIsNone
(
socket
.
getdefaulttimeout
())
url
=
"http://www.example.com"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
):
socket
.
setdefaulttimeout
(
60
)
try
:
...
...
@@ -290,7 +290,7 @@ class TimeoutTest(unittest.TestCase):
self
.
assertIsNone
(
u
.
fp
.
raw
.
_sock
.
gettimeout
())
def
test_http_timeout
(
self
):
url
=
"http://www.example.com"
url
=
support
.
TEST_HTTP_URL
with
support
.
transient_internet
(
url
):
u
=
_urlopen_with_retry
(
url
,
timeout
=
120
)
self
.
addCleanup
(
u
.
close
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_urllibnet.py
Dosyayı görüntüle @
a40681dd
...
...
@@ -3,6 +3,7 @@ from test import support
import
contextlib
import
socket
import
urllib.parse
import
urllib.request
import
os
import
email.message
...
...
@@ -24,8 +25,9 @@ class URLTimeoutTest(unittest.TestCase):
socket
.
setdefaulttimeout
(
None
)
def
testURLread
(
self
):
with
support
.
transient_internet
(
"www.example.com"
):
f
=
urllib
.
request
.
urlopen
(
"http://www.example.com/"
)
domain
=
urllib
.
parse
.
urlparse
(
support
.
TEST_HTTP_URL
)
.
netloc
with
support
.
transient_internet
(
domain
):
f
=
urllib
.
request
.
urlopen
(
support
.
TEST_HTTP_URL
)
f
.
read
()
...
...
This diff is collapsed.
Click to expand it.
Misc/NEWS.d/next/Tests/2019-02-21-14-23-51.bpo-36019.zS_OUi.rst
0 → 100644
Dosyayı görüntüle @
a40681dd
Add test.support.TEST_HTTP_URL and replace references of http://www.example.com
by this new constant. Contributed by Stéphane Wirtel.
This diff is collapsed.
Click to expand it.
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