Django:如何 运行 针对空(未填充)数据库进行测试
Django: How to run tests against empty (non populated) database
通过运行 './manage.py 测试',将本地'postgres' 数据库中的数据填充到'test_postgres' 数据库中。我无法找到方法,如何禁用此行为。
通过 运行 './manage.py test',我想获得未填充的数据库并应用迁移。
class Local(Common):
DEBUG = True
# Testing
INSTALLED_APPS = Common.INSTALLED_APPS
INSTALLED_APPS += ('django_nose',)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
BASE_DIR,
'-s',
'--nologcapture',
'--with-coverage',
'--with-progressive'
]
# Postgres
DATABASES = {
'default': dj_database_url.config(
default='postgres://postgres:@postgres:5432/postgres',
conn_max_age=int(os.getenv('POSTGRES_CONN_MAX_AGE', 600)),
)
}
By running './manage.py test', data from local 'postgres' database are populated into 'test_postgres' database.
不,不是。 Django 将为每个测试创建一个新的空数据库。
通过运行 './manage.py 测试',将本地'postgres' 数据库中的数据填充到'test_postgres' 数据库中。我无法找到方法,如何禁用此行为。 通过 运行 './manage.py test',我想获得未填充的数据库并应用迁移。
class Local(Common):
DEBUG = True
# Testing
INSTALLED_APPS = Common.INSTALLED_APPS
INSTALLED_APPS += ('django_nose',)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
BASE_DIR,
'-s',
'--nologcapture',
'--with-coverage',
'--with-progressive'
]
# Postgres
DATABASES = {
'default': dj_database_url.config(
default='postgres://postgres:@postgres:5432/postgres',
conn_max_age=int(os.getenv('POSTGRES_CONN_MAX_AGE', 600)),
)
}
By running './manage.py test', data from local 'postgres' database are populated into 'test_postgres' database.
不,不是。 Django 将为每个测试创建一个新的空数据库。