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
a4f23eba
Kaydet (Commit)
a4f23eba
authored
Eyl 15, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23421 -- Corrected TEST SERIALIZE setting.
Thanks gkoller for the report.
üst
c692e37b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
33 deletions
+90
-33
runner.py
django/test/runner.py
+1
-1
settings.txt
docs/ref/settings.txt
+13
-0
1.7.1.txt
docs/releases/1.7.1.txt
+3
-0
advanced.txt
docs/topics/testing/advanced.txt
+8
-2
tests.py
tests/test_runner/tests.py
+65
-30
No files found.
django/test/runner.py
Dosyayı görüntüle @
a4f23eba
...
@@ -301,7 +301,7 @@ def setup_databases(verbosity, interactive, keepdb=False, **kwargs):
...
@@ -301,7 +301,7 @@ def setup_databases(verbosity, interactive, keepdb=False, **kwargs):
verbosity
,
verbosity
,
autoclobber
=
not
interactive
,
autoclobber
=
not
interactive
,
keepdb
=
keepdb
,
keepdb
=
keepdb
,
serialize
=
connection
.
settings_dict
.
get
(
"TEST
_
SERIALIZE"
,
True
),
serialize
=
connection
.
settings_dict
.
get
(
"TEST
"
,
{})
.
get
(
"
SERIALIZE"
,
True
),
)
)
destroy
=
True
destroy
=
True
else
:
else
:
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
a4f23eba
...
@@ -683,6 +683,19 @@ test database will use the name ``'test_' + DATABASE_NAME``.
...
@@ -683,6 +683,19 @@ test database will use the name ``'test_' + DATABASE_NAME``.
See :ref:`the-test-database`.
See :ref:`the-test-database`.
.. setting:: TEST_SERIALIZE
SERIALIZE
^^^^^^^^^
.. versionadded:: 1.7.1
Boolean value to control whether or not the default test runnner serializes the
database into an in-memory JSON string before running tests (used to restore
the database state between tests if you don't have transactions). You can set
this to ``False`` to speed up creation time if you don't have any test classes
with :ref:`serialized_rollback=True <test-case-serialized-rollback>`.
.. setting:: TEST_CREATE
.. setting:: TEST_CREATE
CREATE_DB
CREATE_DB
...
...
docs/releases/1.7.1.txt
Dosyayı görüntüle @
a4f23eba
...
@@ -70,3 +70,6 @@ Bugfixes
...
@@ -70,3 +70,6 @@ Bugfixes
* Made ``migrations.RunSQL`` no longer require percent sign escaping. This is
* Made ``migrations.RunSQL`` no longer require percent sign escaping. This is
now consistent with ``cursor.execute()`` (:ticket:`23426`).
now consistent with ``cursor.execute()`` (:ticket:`23426`).
* Made the :setting:`SERIALIZE <TEST_SERIALIZE>` entry in the
:setting:`TEST <DATABASE-TEST>` dictionary usable (:ticket:`23421`).
docs/topics/testing/advanced.txt
Dosyayı görüntüle @
a4f23eba
...
@@ -525,8 +525,14 @@ can be useful during testing.
...
@@ -525,8 +525,14 @@ can be useful during testing.
``serialize`` determines if Django serializes the database into an
``serialize`` determines if Django serializes the database into an
in-memory JSON string before running tests (used to restore the database
in-memory JSON string before running tests (used to restore the database
state between tests if you don't have transactions). You can set this to
state between tests if you don't have transactions). You can set this to
False to significantly speed up creation time if you know you don't need
``False`` to speed up creation time if you don't have any test classes
data persistence outside of test fixtures.
with :ref:`serialized_rollback=True <test-case-serialized-rollback>`.
.. versionadded:: 1.7.1
If you are using the default test runner, you can control this with the
the :setting:`SERIALIZE <TEST_SERIALIZE>` entry in the
:setting:`TEST <DATABASE-TEST>` dictionary
``keepdb`` determines if the test run should use an existing
``keepdb`` determines if the test run should use an existing
database, or create a new one. If ``True``, the existing
database, or create a new one. If ``True``, the existing
...
...
tests/test_runner/tests.py
Dosyayı görüntüle @
a4f23eba
...
@@ -5,9 +5,10 @@ from __future__ import unicode_literals
...
@@ -5,9 +5,10 @@ from __future__ import unicode_literals
import
unittest
import
unittest
from
django
import
db
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.management
import
call_command
from
django.core.management
import
call_command
from
django
import
db
from
django
.db.backends.dummy.base
import
DatabaseCreation
from
django.test
import
runner
,
TestCase
,
TransactionTestCase
,
skipUnlessDBFeature
from
django.test
import
runner
,
TestCase
,
TransactionTestCase
,
skipUnlessDBFeature
from
django.test.testcases
import
connections_support_transactions
from
django.test.testcases
import
connections_support_transactions
from
django.test.utils
import
override_system_checks
from
django.test.utils
import
override_system_checks
...
@@ -299,38 +300,72 @@ class AliasedDefaultTestSetupTest(unittest.TestCase):
...
@@ -299,38 +300,72 @@ class AliasedDefaultTestSetupTest(unittest.TestCase):
db
.
connections
=
old_db_connections
db
.
connections
=
old_db_connections
class
AliasedDatabaseTeardownTest
(
unittest
.
TestCase
):
class
SetupDatabasesTests
(
unittest
.
TestCase
):
def
test_setup_aliased_databases
(
self
):
from
django.db.backends.dummy.base
import
DatabaseCreation
runner_instance
=
runner
.
DiscoverRunner
(
verbosity
=
0
)
old_db_connections
=
db
.
connections
old_destroy_test_db
=
DatabaseCreation
.
destroy_test_db
old_create_test_db
=
DatabaseCreation
.
create_test_db
try
:
destroyed_names
=
[]
DatabaseCreation
.
destroy_test_db
=
lambda
self
,
old_database_name
,
verbosity
=
1
,
keepdb
=
False
,
serialize
=
True
:
destroyed_names
.
append
(
old_database_name
)
DatabaseCreation
.
create_test_db
=
lambda
self
,
verbosity
=
1
,
autoclobber
=
False
,
keepdb
=
False
,
serialize
=
True
:
self
.
_get_test_db_name
()
db
.
connections
=
db
.
ConnectionHandler
({
def
setUp
(
self
):
'default'
:
{
self
.
_old_db_connections
=
db
.
connections
'ENGINE'
:
'django.db.backends.dummy'
,
self
.
_old_destroy_test_db
=
DatabaseCreation
.
destroy_test_db
'NAME'
:
'dbname'
,
self
.
_old_create_test_db
=
DatabaseCreation
.
create_test_db
},
self
.
runner_instance
=
runner
.
DiscoverRunner
(
verbosity
=
0
)
'other'
:
{
'ENGINE'
:
'django.db.backends.dummy'
,
'NAME'
:
'dbname'
,
}
})
old_config
=
runner_instance
.
setup_databases
()
def
tearDown
(
self
):
runner_instance
.
teardown_databases
(
old_config
)
DatabaseCreation
.
create_test_db
=
self
.
_old_create_test_db
DatabaseCreation
.
destroy_test_db
=
self
.
_old_destroy_test_db
db
.
connections
=
self
.
_old_db_connections
self
.
assertEqual
(
destroyed_names
.
count
(
'dbname'
),
1
)
def
test_setup_aliased_databases
(
self
):
finally
:
destroyed_names
=
[]
DatabaseCreation
.
create_test_db
=
old_create_test_db
DatabaseCreation
.
destroy_test_db
=
(
DatabaseCreation
.
destroy_test_db
=
old_destroy_test_db
lambda
self
,
old_database_name
,
verbosity
=
1
,
keepdb
=
False
,
serialize
=
True
:
db
.
connections
=
old_db_connections
destroyed_names
.
append
(
old_database_name
)
)
DatabaseCreation
.
create_test_db
=
(
lambda
self
,
verbosity
=
1
,
autoclobber
=
False
,
keepdb
=
False
,
serialize
=
True
:
self
.
_get_test_db_name
()
)
db
.
connections
=
db
.
ConnectionHandler
({
'default'
:
{
'ENGINE'
:
'django.db.backends.dummy'
,
'NAME'
:
'dbname'
,
},
'other'
:
{
'ENGINE'
:
'django.db.backends.dummy'
,
'NAME'
:
'dbname'
,
}
})
old_config
=
self
.
runner_instance
.
setup_databases
()
self
.
runner_instance
.
teardown_databases
(
old_config
)
self
.
assertEqual
(
destroyed_names
.
count
(
'dbname'
),
1
)
def
test_serialization
(
self
):
serialize
=
[]
DatabaseCreation
.
create_test_db
=
(
lambda
*
args
,
**
kwargs
:
serialize
.
append
(
kwargs
.
get
(
'serialize'
))
)
db
.
connections
=
db
.
ConnectionHandler
({
'default'
:
{
'ENGINE'
:
'django.db.backends.dummy'
,
},
})
self
.
runner_instance
.
setup_databases
()
self
.
assertEqual
(
serialize
,
[
True
])
def
test_serialized_off
(
self
):
serialize
=
[]
DatabaseCreation
.
create_test_db
=
(
lambda
*
args
,
**
kwargs
:
serialize
.
append
(
kwargs
.
get
(
'serialize'
))
)
db
.
connections
=
db
.
ConnectionHandler
({
'default'
:
{
'ENGINE'
:
'django.db.backends.dummy'
,
'TEST'
:
{
'SERIALIZE'
:
False
},
},
})
self
.
runner_instance
.
setup_databases
()
self
.
assertEqual
(
serialize
,
[
False
])
class
DeprecationDisplayTest
(
AdminScriptTestCase
):
class
DeprecationDisplayTest
(
AdminScriptTestCase
):
...
...
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