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
34a50e99
Kaydet (Commit)
34a50e99
authored
Mar 26, 2013
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added regression test for custom SQL containing percents
Refs #3485.
üst
f2a0be61
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
simple.sql
tests/initial_sql_regress/sql/simple.sql
+1
-0
tests.py
tests/initial_sql_regress/tests.py
+28
-9
No files found.
tests/initial_sql_regress/sql/simple.sql
Dosyayı görüntüle @
34a50e99
...
@@ -7,5 +7,6 @@ INSERT INTO
...
@@ -7,5 +7,6 @@ INSERT INTO
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'George'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'George'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'Miles O
''
Brien'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'Miles O
''
Brien'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'Semicolon;Man'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'Semicolon;Man'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'"100%" of % are not placeholders'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'This line has a Windows line ending'
);
INSERT
INTO
initial_sql_regress_simple
(
name
)
VALUES
(
'This line has a Windows line ending'
);
tests/initial_sql_regress/tests.py
Dosyayı görüntüle @
34a50e99
...
@@ -2,27 +2,46 @@ from django.core.management.color import no_style
...
@@ -2,27 +2,46 @@ from django.core.management.color import no_style
from
django.core.management.sql
import
custom_sql_for_model
from
django.core.management.sql
import
custom_sql_for_model
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
.models
import
Simple
from
.models
import
Simple
class
InitialSQLTests
(
TestCase
):
class
InitialSQLTests
(
TestCase
):
# The format of the included SQL file for this test suite is important.
"""
# It must end with a trailing newline in order to test the fix for #2161.
The format of the included SQL file for this test suite is important.
It must end with a trailing newline in order to test the fix for #2161.
"""
def
test_initial_sql
(
self
):
def
test_initial_sql
(
self
):
# As pointed out by #14661, test data loaded by custom SQL
"""
# can't be relied upon; as a result, the test framework flushes the
As pointed out by #14661, test data loaded by custom SQL
# data contents before every test. This test validates that this has
can't be relied upon; as a result, the test framework flushes the
# occurred.
data contents before every test. This test validates that this has
occurred.
"""
self
.
assertEqual
(
Simple
.
objects
.
count
(),
0
)
self
.
assertEqual
(
Simple
.
objects
.
count
(),
0
)
def
test_custom_sql
(
self
):
def
test_custom_sql
(
self
):
# Simulate the custom SQL loading by syncdb
"""
Simulate the custom SQL loading by syncdb.
"""
connection
=
connections
[
DEFAULT_DB_ALIAS
]
connection
=
connections
[
DEFAULT_DB_ALIAS
]
custom_sql
=
custom_sql_for_model
(
Simple
,
no_style
(),
connection
)
custom_sql
=
custom_sql_for_model
(
Simple
,
no_style
(),
connection
)
self
.
assertEqual
(
len
(
custom_sql
),
8
)
self
.
assertEqual
(
len
(
custom_sql
),
9
)
cursor
=
connection
.
cursor
()
cursor
=
connection
.
cursor
()
for
sql
in
custom_sql
:
for
sql
in
custom_sql
:
cursor
.
execute
(
sql
)
cursor
.
execute
(
sql
)
self
.
assertEqual
(
Simple
.
objects
.
count
(),
8
)
self
.
assertEqual
(
Simple
.
objects
.
count
(),
9
)
self
.
assertEqual
(
Simple
.
objects
.
get
(
name__contains
=
'placeholders'
)
.
name
,
'"100
%
" of
%
are not placeholders'
)
@override_settings
(
DEBUG
=
True
)
def
test_custom_sql_debug
(
self
):
"""
Same test, ensure that CursorDebugWrapper doesn't alter sql loading
(#3485).
"""
self
.
test_custom_sql
()
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