1 Star 0 Fork 0

mm1994uestc/openag-device-software

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
conftest.py 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
rob baynes 提交于 2018-09-24 18:47 . remove execute perms
import os, django, pytest
from django.conf import settings
# We manually designate settings we will be using in an environment variable.
# This is similar to what occurs in the `manage.py`
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
# `pytest` automatically calls this function once when tests are run.
def pytest_configure():
settings.DEBUG = False
# If you have any test specific settings, you can declare them here,
# e.g.
# settings.PASSWORD_HASHERS = (
# 'django.contrib.auth.hashers.MD5PasswordHasher',
# )
django.setup()
# Give django database access to all tests.
# The alternative is to mark just the test functions that need DB access with:
# @pytest.mark.django_db
@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass
"""
We want django / pytest to recreate a TEST DB each test run, so DON'T
override the default fixture by using the function below.
Instead look in app/settings.py at the DATABASES / 'default' / 'TEST' section.
# Configure access to our REAL database. Not good for tests, because the DB
# state changes when we run the app!
@pytest.fixture(scope='session')
def django_db_setup():
settings.DATABASES['default'] = {
'USER': 'openag',
'PASSWORD': 'openag',
'NAME': 'test_openag_brain',
'ENGINE': 'django.db.backends.postgresql',
}
"""
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mm1994uestc/openag-device-software.git
[email protected]:mm1994uestc/openag-device-software.git
mm1994uestc
openag-device-software
openag-device-software
master

搜索帮助