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
5c85e3f3
Kaydet (Commit)
5c85e3f3
authored
Ock 03, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
test_timeout: move testRecvfromTimeout() to a UDP-specific test case
Fix a ResourceWarning(unclosed socket).
üst
109761ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
22 deletions
+38
-22
test_timeout.py
Lib/test/test_timeout.py
+38
-22
No files found.
Lib/test/test_timeout.py
Dosyayı görüntüle @
5c85e3f3
...
...
@@ -88,8 +88,6 @@ class CreationTestCase(unittest.TestCase):
class
TimeoutTestCase
(
unittest
.
TestCase
):
"""Test case for socket.socket() timeout functions"""
# There are a number of tests here trying to make sure that an operation
# doesn't take too much longer than expected. But competing machine
# activity makes it inevitable that such tests will fail at times.
...
...
@@ -98,14 +96,22 @@ class TimeoutTestCase(unittest.TestCase):
# solution.
fuzz
=
2.0
localhost
=
'127.0.0.1'
def
setUp
(
self
):
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
addr_remote
=
(
'www.python.org.'
,
80
)
self
.
localhost
=
'127.0.0.1'
raise
NotImplementedError
()
def
tearDown
(
self
):
self
.
sock
.
close
()
class
TCPTimeoutTestCase
(
TimeoutTestCase
):
"""TCP test case for socket.socket() timeout functions"""
def
setUp
(
self
):
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
addr_remote
=
(
'www.python.org.'
,
80
)
def
testConnectTimeout
(
self
):
# Choose a private address that is unlikely to exist to prevent
# failures due to the connect succeeding before the timeout.
...
...
@@ -161,10 +167,31 @@ class TimeoutTestCase(unittest.TestCase):
"timeout (
%
g) is
%
g seconds more than expected (
%
g)"
%
(
_delta
,
self
.
fuzz
,
_timeout
))
def
testSend
(
self
):
# Test send() timeout
# couldn't figure out how to test it
pass
def
testSendto
(
self
):
# Test sendto() timeout
# couldn't figure out how to test it
pass
def
testSendall
(
self
):
# Test sendall() timeout
# couldn't figure out how to test it
pass
class
UDPTimeoutTestCase
(
TimeoutTestCase
):
"""UDP test case for socket.socket() timeout functions"""
def
setUp
(
self
):
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
def
testRecvfromTimeout
(
self
):
# Test recvfrom() timeout
_timeout
=
2
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
self
.
sock
.
settimeout
(
_timeout
)
# Prevent "Address already in use" socket exceptions
support
.
bind_port
(
self
.
sock
,
self
.
localhost
)
...
...
@@ -178,25 +205,14 @@ class TimeoutTestCase(unittest.TestCase):
"timeout (
%
g) is
%
g seconds more than expected (
%
g)"
%
(
_delta
,
self
.
fuzz
,
_timeout
))
def
testSend
(
self
):
# Test send() timeout
# couldn't figure out how to test it
pass
def
testSendto
(
self
):
# Test sendto() timeout
# couldn't figure out how to test it
pass
def
testSendall
(
self
):
# Test sendall() timeout
# couldn't figure out how to test it
pass
def
test_main
():
support
.
requires
(
'network'
)
support
.
run_unittest
(
CreationTestCase
,
TimeoutTestCase
)
support
.
run_unittest
(
CreationTestCase
,
TCPTimeoutTestCase
,
UDPTimeoutTestCase
,
)
if
__name__
==
"__main__"
:
test_main
()
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