Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
f6cd669f
Kaydet (Commit)
f6cd669f
authored
Agu 19, 2016
tarafından
Chris Jerdonek
Kaydeden (comit)
Tim Graham
Agu 19, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22414 -- Ensured that LiveServerTestCase closes connections.
üst
7b08e01c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
testcases.py
django/test/testcases.py
+3
-1
test_liveserverthread.py
tests/servers/test_liveserverthread.py
+28
-0
tests.py
tests/servers/tests.py
+2
-1
No files found.
django/test/testcases.py
Dosyayı görüntüle @
f6cd669f
...
...
@@ -1262,6 +1262,8 @@ class LiveServerThread(threading.Thread):
except
Exception
as
e
:
self
.
error
=
e
self
.
is_ready
.
set
()
finally
:
connections
.
close_all
()
def
_create_server
(
self
,
port
):
return
WSGIServer
((
self
.
host
,
port
),
QuietWSGIRequestHandler
,
allow_reuse_address
=
False
)
...
...
@@ -1271,6 +1273,7 @@ class LiveServerThread(threading.Thread):
# Stop the WSGI server
self
.
httpd
.
shutdown
()
self
.
httpd
.
server_close
()
self
.
join
()
class
LiveServerTestCase
(
TransactionTestCase
):
...
...
@@ -1335,7 +1338,6 @@ class LiveServerTestCase(TransactionTestCase):
if
hasattr
(
cls
,
'server_thread'
):
# Terminate the live server's thread
cls
.
server_thread
.
terminate
()
cls
.
server_thread
.
join
()
# Restore sqlite in-memory database connections' non-shareability
for
conn
in
connections
.
all
():
...
...
tests/servers/test_liveserverthread.py
0 → 100644
Dosyayı görüntüle @
f6cd669f
from
django.db
import
DEFAULT_DB_ALIAS
,
connections
from
django.test
import
LiveServerTestCase
,
TestCase
class
LiveServerThreadTest
(
TestCase
):
def
run_live_server_thread
(
self
,
connections_override
=
None
):
thread
=
LiveServerTestCase
.
_create_server_thread
(
connections_override
)
thread
.
daemon
=
True
thread
.
start
()
thread
.
is_ready
.
wait
()
thread
.
terminate
()
def
test_closes_connections
(
self
):
conn
=
connections
[
DEFAULT_DB_ALIAS
]
if
conn
.
vendor
==
'sqlite'
and
conn
.
is_in_memory_db
():
self
.
skipTest
(
"the sqlite backend's close() method is a no-op when using an in-memory database"
)
# Pass a connection to the thread to check they are being closed.
connections_override
=
{
DEFAULT_DB_ALIAS
:
conn
}
saved_sharing
=
conn
.
allow_thread_sharing
try
:
conn
.
allow_thread_sharing
=
True
self
.
assertTrue
(
conn
.
is_usable
())
self
.
run_live_server_thread
(
connections_override
)
self
.
assertFalse
(
conn
.
is_usable
())
finally
:
conn
.
allow_thread_sharing
=
saved_sharing
tests/servers/tests.py
Dosyayı görüntüle @
f6cd669f
...
...
@@ -153,4 +153,5 @@ class LiveServerPort(LiveServerBase):
"Acquired duplicate server addresses for server threads:
%
s"
%
self
.
live_server_url
)
finally
:
TestCase
.
tearDownClass
()
if
hasattr
(
TestCase
,
'server_thread'
):
TestCase
.
server_thread
.
terminate
()
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