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
64f6e037
Kaydet (Commit)
64f6e037
authored
Kas 26, 2012
tarafından
Anssi Kääriäinen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Made some tests behave nicer re connection handling
üst
905ea961
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
17 deletions
+15
-17
tests.py
tests/regressiontests/backends/tests.py
+11
-5
tests.py
tests/regressiontests/delete_regress/tests.py
+4
-12
No files found.
tests/regressiontests/backends/tests.py
Dosyayı görüntüle @
64f6e037
...
...
@@ -559,21 +559,27 @@ class ThreadTests(TestCase):
"""
connections_set
=
set
()
connection
.
cursor
()
connections_set
.
add
(
connection
.
connection
)
connections_set
.
add
(
connection
)
def
runner
():
from
django.db
import
connection
# Passing django.db.connection between threads doesn't work while
# connections[DEFAULT_DB_ALIAS] does.
from
django.db
import
connections
connection
=
connections
[
DEFAULT_DB_ALIAS
]
connection
.
cursor
()
connections_set
.
add
(
connection
.
connection
)
connections_set
.
add
(
connection
)
for
x
in
range
(
2
):
t
=
threading
.
Thread
(
target
=
runner
)
t
.
start
()
t
.
join
()
self
.
assertEqual
(
len
(
connections_set
),
3
)
# Check that each created connection got different inner connection.
self
.
assertEqual
(
len
(
set
([
conn
.
connection
for
conn
in
connections_set
])),
3
)
# Finish by closing the connections opened by the other threads (the
# connection opened in the main thread will automatically be closed on
# teardown).
for
conn
in
connections_set
:
if
conn
!=
connection
.
connection
:
if
conn
!=
connection
:
conn
.
close
()
def
test_connections_thread_local
(
self
):
...
...
tests/regressiontests/delete_regress/tests.py
Dosyayı görüntüle @
64f6e037
...
...
@@ -3,7 +3,8 @@ from __future__ import absolute_import
import
datetime
from
django.conf
import
settings
from
django.db
import
backend
,
transaction
,
DEFAULT_DB_ALIAS
,
models
from
django.db
import
transaction
,
DEFAULT_DB_ALIAS
,
models
from
django.db.utils
import
ConnectionHandler
from
django.test
import
TestCase
,
TransactionTestCase
,
skipUnlessDBFeature
from
.models
import
(
Book
,
Award
,
AwardNote
,
Person
,
Child
,
Toy
,
PlayedWith
,
...
...
@@ -17,17 +18,8 @@ from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
class
DeleteLockingTest
(
TransactionTestCase
):
def
setUp
(
self
):
# Create a second connection to the default database
conn_settings
=
settings
.
DATABASES
[
DEFAULT_DB_ALIAS
]
self
.
conn2
=
backend
.
DatabaseWrapper
({
'HOST'
:
conn_settings
[
'HOST'
],
'NAME'
:
conn_settings
[
'NAME'
],
'OPTIONS'
:
conn_settings
[
'OPTIONS'
],
'PASSWORD'
:
conn_settings
[
'PASSWORD'
],
'PORT'
:
conn_settings
[
'PORT'
],
'USER'
:
conn_settings
[
'USER'
],
'TIME_ZONE'
:
settings
.
TIME_ZONE
,
})
new_connections
=
ConnectionHandler
(
settings
.
DATABASES
)
self
.
conn2
=
new_connections
[
DEFAULT_DB_ALIAS
]
# Put both DB connections into managed transaction mode
transaction
.
enter_transaction_management
()
transaction
.
managed
(
True
)
...
...
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