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
98b3b14a
Kaydet (Commit)
98b3b14a
authored
May 14, 2017
tarafından
François Freitag
Kaydeden (comit)
Tim Graham
May 18, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28203 -- Ignored connection configuration queries in assertNumQueries().
üst
f599747f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
utils.py
django/test/utils.py
+3
-0
2.0.txt
docs/releases/2.0.txt
+5
-0
tests.py
tests/test_utils/tests.py
+28
-1
No files found.
django/test/utils.py
Dosyayı görüntüle @
98b3b14a
...
...
@@ -601,6 +601,9 @@ class CaptureQueriesContext:
def
__enter__
(
self
):
self
.
force_debug_cursor
=
self
.
connection
.
force_debug_cursor
self
.
connection
.
force_debug_cursor
=
True
# Run any initialization queries if needed so that they won't be
# included as part of the count.
self
.
connection
.
ensure_connection
()
self
.
initial_queries
=
len
(
self
.
connection
.
queries_log
)
self
.
final_queries
=
None
request_started
.
disconnect
(
reset_queries
)
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
98b3b14a
...
...
@@ -334,6 +334,11 @@ Miscellaneous
* The ``FIRST_DAY_OF_WEEK`` and ``NUMBER_GROUPING`` format settings are now
kept as integers in JavaScript and JSON i18n view outputs.
* :meth:`~django.test.TransactionTestCase.assertNumQueries` now ignores
connection configuration queries. Previously, if a test opened a new database
connection, those queries could be included as part of the
``assertNumQueries()`` count.
.. _deprecated-features-2.0:
Features deprecated in 2.0
...
...
tests/test_utils/tests.py
Dosyayı görüntüle @
98b3b14a
...
...
@@ -14,7 +14,8 @@ from django.forms import EmailField, IntegerField
from
django.http
import
HttpResponse
from
django.template.loader
import
render_to_string
from
django.test
import
(
SimpleTestCase
,
TestCase
,
skipIfDBFeature
,
skipUnlessDBFeature
,
SimpleTestCase
,
TestCase
,
TransactionTestCase
,
skipIfDBFeature
,
skipUnlessDBFeature
,
)
from
django.test.html
import
HTMLParseError
,
parse_html
from
django.test.utils
import
(
...
...
@@ -157,6 +158,32 @@ class AssertNumQueriesTests(TestCase):
self
.
assertNumQueries
(
2
,
test_func
)
@unittest.skipUnless
(
connection
.
vendor
!=
'sqlite'
or
not
connection
.
is_in_memory_db
(),
'For SQLite in-memory tests, closing the connection destroys the database.'
)
class
AssertNumQueriesUponConnectionTests
(
TransactionTestCase
):
available_apps
=
[]
def
test_ignores_connection_configuration_queries
(
self
):
real_ensure_connection
=
connection
.
ensure_connection
connection
.
close
()
def
make_configuration_query
():
is_opening_connection
=
connection
.
connection
is
None
real_ensure_connection
()
if
is_opening_connection
:
# Avoid infinite recursion. Creating a cursor calls
# ensure_connection() which is currently mocked by this method.
connection
.
cursor
()
.
execute
(
'SELECT 1'
+
connection
.
features
.
bare_select_suffix
)
ensure_connection
=
'django.db.backends.base.base.BaseDatabaseWrapper.ensure_connection'
with
mock
.
patch
(
ensure_connection
,
side_effect
=
make_configuration_query
):
with
self
.
assertNumQueries
(
1
):
list
(
Car
.
objects
.
all
())
class
AssertQuerysetEqualTests
(
TestCase
):
def
setUp
(
self
):
self
.
p1
=
Person
.
objects
.
create
(
name
=
'p1'
)
...
...
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