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
f6087ca9
Kaydet (Commit)
f6087ca9
authored
Tem 12, 2009
tarafından
Kristján Valur Jónsson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
merging revision 73986 from trunk:
http://bugs.python.org/issue6267
Add more tests for the xlmrpc.ServerProxy
üst
6db9470e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
4 deletions
+41
-4
test_xmlrpc.py
Lib/test/test_xmlrpc.py
+41
-4
No files found.
Lib/test/test_xmlrpc.py
Dosyayı görüntüle @
f6087ca9
...
...
@@ -322,13 +322,14 @@ def is_unavailable_exception(e):
class
BaseServerTestCase
(
unittest
.
TestCase
):
requestHandler
=
None
request_count
=
1
def
setUp
(
self
):
# enable traceback reporting
xmlrpc
.
server
.
SimpleXMLRPCServer
.
_send_traceback_header
=
True
self
.
evt
=
threading
.
Event
()
# start server thread to handle requests
serv_args
=
(
self
.
evt
,
1
,
self
.
requestHandler
)
serv_args
=
(
self
.
evt
,
self
.
request_count
,
self
.
requestHandler
)
threading
.
Thread
(
target
=
http_server
,
args
=
serv_args
)
.
start
()
# wait for the server to be ready
...
...
@@ -484,7 +485,7 @@ class SimpleServerTestCase(BaseServerTestCase):
#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
#does indeed serve subsequent requests on the same connection
class
KeepaliveServerTestCase
(
BaseServerTestCase
):
class
Base
KeepaliveServerTestCase
(
BaseServerTestCase
):
#a request handler that supports keep-alive and logs requests into a
#class variable
class
RequestHandler
(
xmlrpc
.
server
.
SimpleXMLRPCRequestHandler
):
...
...
@@ -493,10 +494,11 @@ class KeepaliveServerTestCase(BaseServerTestCase):
myRequests
=
[]
def
handle
(
self
):
self
.
myRequests
.
append
([])
self
.
reqidx
=
len
(
self
.
myRequests
)
-
1
return
self
.
parentClass
.
handle
(
self
)
def
handle_one_request
(
self
):
result
=
self
.
parentClass
.
handle_one_request
(
self
)
self
.
myRequests
[
-
1
]
.
append
(
self
.
raw_requestline
)
self
.
myRequests
[
self
.
reqidx
]
.
append
(
self
.
raw_requestline
)
return
result
requestHandler
=
RequestHandler
...
...
@@ -505,6 +507,9 @@ class KeepaliveServerTestCase(BaseServerTestCase):
self
.
RequestHandler
.
myRequests
=
[]
return
BaseServerTestCase
.
setUp
(
self
)
#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
#does indeed serve subsequent requests on the same connection
class
KeepaliveServerTestCase1
(
BaseKeepaliveServerTestCase
):
def
test_two
(
self
):
p
=
xmlrpclib
.
ServerProxy
(
URL
)
#do three requests.
...
...
@@ -519,6 +524,37 @@ class KeepaliveServerTestCase(BaseServerTestCase):
#due to thread scheduling)
self
.
assertGreaterEqual
(
len
(
self
.
RequestHandler
.
myRequests
[
-
1
]),
2
)
#test special attribute access on the serverproxy, through the __call__
#function.
class
KeepaliveServerTestCase2
(
BaseKeepaliveServerTestCase
):
#ask for two keepalive requests to be handled.
request_count
=
2
def
test_close
(
self
):
p
=
xmlrpclib
.
ServerProxy
(
URL
)
#do some requests with close.
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
p
(
"close"
)()
#this should trigger a new keep-alive request
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
#they should have all been two request handlers, each having logged at least
#two complete requests
self
.
assertEqual
(
len
(
self
.
RequestHandler
.
myRequests
),
2
)
self
.
assertGreaterEqual
(
len
(
self
.
RequestHandler
.
myRequests
[
-
1
]),
2
)
self
.
assertGreaterEqual
(
len
(
self
.
RequestHandler
.
myRequests
[
-
2
]),
2
)
def
test_transport
(
self
):
p
=
xmlrpclib
.
ServerProxy
(
URL
)
#do some requests with close.
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
p
(
"transport"
)
.
close
()
#same as above, really.
self
.
assertEqual
(
p
.
pow
(
6
,
8
),
6
**
8
)
self
.
assertEqual
(
len
(
self
.
RequestHandler
.
myRequests
),
2
)
#A test case that verifies that gzip encoding works in both directions
#(for a request and the response)
class
GzipServerTestCase
(
BaseServerTestCase
):
...
...
@@ -761,7 +797,8 @@ def test_main():
xmlrpc_tests
=
[
XMLRPCTestCase
,
HelperTestCase
,
DateTimeTestCase
,
BinaryTestCase
,
FaultTestCase
]
xmlrpc_tests
.
append
(
SimpleServerTestCase
)
xmlrpc_tests
.
append
(
KeepaliveServerTestCase
)
xmlrpc_tests
.
append
(
KeepaliveServerTestCase1
)
xmlrpc_tests
.
append
(
KeepaliveServerTestCase2
)
xmlrpc_tests
.
append
(
GzipServerTestCase
)
xmlrpc_tests
.
append
(
ServerProxyTestCase
)
xmlrpc_tests
.
append
(
FailingServerTestCase
)
...
...
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