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
0fba4c0e
Kaydet (Commit)
0fba4c0e
authored
Haz 24, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22487: Don't flush out data from before normal TestCases
üst
c33447a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
migrate.py
django/core/management/commands/migrate.py
+12
-0
creation.py
django/db/backends/creation.py
+1
-8
tests.py
tests/migration_test_data_persistence/tests.py
+6
-9
No files found.
django/core/management/commands/migrate.py
Dosyayı görüntüle @
0fba4c0e
...
...
@@ -129,6 +129,18 @@ class Command(BaseCommand):
else
:
created_models
=
[]
# The test runner requires us to flush after a syncdb but before migrations,
# so do that here.
if
options
.
get
(
"test_flush"
,
False
):
call_command
(
'flush'
,
verbosity
=
max
(
self
.
verbosity
-
1
,
0
),
interactive
=
False
,
database
=
db
,
reset_sequences
=
False
,
inhibit_post_migrate
=
True
,
)
# Migrate!
if
self
.
verbosity
>=
1
:
self
.
stdout
.
write
(
self
.
style
.
MIGRATE_HEADING
(
"Running migrations:"
))
...
...
django/db/backends/creation.py
Dosyayı görüntüle @
0fba4c0e
...
...
@@ -380,6 +380,7 @@ class BaseDatabaseCreation(object):
interactive
=
False
,
database
=
self
.
connection
.
alias
,
test_database
=
True
,
test_flush
=
True
,
)
# We then serialize the current state of the database into a string
...
...
@@ -389,14 +390,6 @@ class BaseDatabaseCreation(object):
if
serialize
:
self
.
connection
.
_test_serialized_contents
=
self
.
serialize_db_to_string
()
# Finally, we flush the database to clean
call_command
(
'flush'
,
verbosity
=
max
(
verbosity
-
1
,
0
),
interactive
=
False
,
database
=
self
.
connection
.
alias
)
call_command
(
'createcachetable'
,
database
=
self
.
connection
.
alias
)
# Ensure a connection for the side effect of initializing the test database.
...
...
tests/migration_test_data_persistence/tests.py
Dosyayı görüntüle @
0fba4c0e
from
django.test
import
TransactionTestCase
from
django.test
import
TransactionTestCase
,
TestCase
from
.models
import
Book
class
MigrationDataPersistenceTestCase
(
TransactionTestCase
):
"""
Tests that data loaded in migrations is available if we set
serialized_rollback = True
.
serialized_rollback = True
on TransactionTestCase
"""
available_apps
=
[
"migration_test_data_persistence"
]
...
...
@@ -18,16 +18,13 @@ class MigrationDataPersistenceTestCase(TransactionTestCase):
)
class
MigrationDataNo
PersistenceTestCase
(
Transaction
TestCase
):
class
MigrationDataNo
rmalPersistenceTestCase
(
TestCase
):
"""
Tests th
e failure c
ase
Tests th
at data loaded in migrations is available on TestC
ase
"""
available_apps
=
[
"migration_test_data_persistence"
]
serialized_rollback
=
False
def
test_no_persistence
(
self
):
def
test_persistence
(
self
):
self
.
assertEqual
(
Book
.
objects
.
count
(),
0
,
1
,
)
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