Here are the examples of the python api django.conf.settings.configure taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
59 Examples
3
View Complete Implementation : migrate.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : kogan
Copyright BSD 3-Clause "New" or "Revised" License
Author : kogan
def migrate(name):
from django.conf import settings
settings.configure(**SETTINGS_DICT)
import django
django.setup()
from django.core import management
management.call_command("makemigrations", "subscriptions", name=name)
3
View Complete Implementation : migraterunner.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
def main(args):
try:
create_database(args)
# Since this test suite is designed to be ran outside of ./manage.py test, we need to do some setup first.
import django
from django.conf import settings
settings.configure(INSTALLED_APPS=['testmigrationsapp'], DATABASES=DATABASES_FOR_DB[args.db])
django.setup()
management.call_command('migrate', 'testmigrationsapp', verbosity=1)
import django.db
django.db.connections.close_all()
finally:
destroy_database(args)
3
View Complete Implementation : conftest.py
Copyright MIT License
Author : labd
Copyright MIT License
Author : labd
def pytest_configure():
settings.configure(
COGNITO_AWS_REGION="eu-central-1",
COGNITO_USER_POOL="bla",
COGNITO_AUDIENCE="my-client-id",
INSTALLED_APPS=["django.contrib.auth", "django.contrib.contenttypes"],
MIDDLEWARE_CLastES=[],
CACHES={
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "unique-snowflake",
}
},
DATABASES={
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite"}
},
ROOT_URLCONF="urls",
)
3
View Complete Implementation : application_django.py
Copyright MIT License
Author : WolframResearch
Copyright MIT License
Author : WolframResearch
def setUp(self):
from django.conf import settings
settings.configure(
ROOT_URLCONF="wolframwebengine.examples.djangoapp.urls",
ALLOWED_HOSTS="*",
DEBUG=True,
)
import django
django.setup()
from wolframwebengine.examples.djangoapp.urls import session
self.session = session
self.client = Client()
3
View Complete Implementation : conftest.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mirumee
Copyright BSD 3-Clause "New" or "Revised" License
Author : mirumee
def pytest_configure():
settings.configure(
USE_TZ=True,
TIME_ZONE="America/Chicago",
INSTALLED_APPS=["ariadne.contrib.django"],
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
}
],
)
3
View Complete Implementation : conftest.py
Copyright GNU Lesser General Public License v3.0
Author : luxcem
Copyright GNU Lesser General Public License v3.0
Author : luxcem
def pytest_configure():
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
},
SITE_ID=1,
SECRET_KEY="fake-key",
INSTALLED_APPS=(
"django.contrib.auth",
"django.contrib.contenttypes",
"django_und",
"tests",
),
)
3
View Complete Implementation : runtests.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : kogan
Copyright BSD 3-Clause "New" or "Revised" License
Author : kogan
def run_tests():
# First configure settings, then call django.setup() to initialise
from django.conf import settings
settings.configure(**SETTINGS_DICT)
import django
django.setup()
# Now create the test runner
from django.test.utils import get_runner
TestRunner = get_runner(settings)
# And then we run tests and return the results.
test_runner = TestRunner(verbosity=2, interactive=True)
failures = test_runner.run_tests(["tests"])
sys.exit(failures)
3
View Complete Implementation : runner.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
def main(args):
# Since this test suite is designed to be ran outside of ./manage.py test, we need to do some setup first.
import django
from django.conf import settings
settings.configure(INSTALLED_APPS=['testapp'], DATABASES=DATABASES_FOR_DB[args.db], DB_NAME=args.db)
django.setup()
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(top_level=TESTS_DIR, interactive=False, keepdb=False)
if args.testpaths:
paths = ['tests.' + p for p in args.testpaths]
failures = test_runner.run_tests(paths)
else:
failures = test_runner.run_tests(['tests'])
if failures:
sys.exit(1)
3
View Complete Implementation : makemigrationsrunner.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
Copyright BSD 3-Clause "New" or "Revised" License
Author : mattiaslinnap
def main(args):
# Since this test suite is designed to be ran outside of ./manage.py test, we need to do some setup first.
import django
from django.conf import settings
settings.configure(INSTALLED_APPS=['testmigrationsapp'], DATABASES=DATABASES)
django.setup()
management.call_command('makemigrations', 'testmigrationsapp', verbosity=0)
def run(self):
from django.conf import settings
settings.configure(
DATABASES={'default': {
'NAME': ':memory:',
'ENGINE': 'django.db.backends.sqlite3'}
},
INSTALLED_APPS=('django_uidfield', 'django.contrib.contenttypes')
)
from django.core.management import call_command
import django
django.setup()
call_command('test', 'django_uidfield')
3
View Complete Implementation : manage.py
Copyright MIT License
Author : WolframResearch
Copyright MIT License
Author : WolframResearch
def main():
try:
from django.core.management import execute_from_command_line
from django.conf import settings
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
settings.configure(
ROOT_URLCONF="wolframwebengine.examples.djangoapp.urls", ALLOWED_HOSTS="*", DEBUG=True
)
execute_from_command_line(sys.argv)
3
View Complete Implementation : runtests.py
Copyright MIT License
Author : sjoerdjob
Copyright MIT License
Author : sjoerdjob
def main():
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.abspath(os.path.join(BASE_DIR, '..')))
django.conf.settings.configure()
django.setup()
arguments = list(sys.argv)
arguments.insert(1, 'test')
django.core.management.execute_from_command_line(arguments)
3
View Complete Implementation : command_utils.py
Copyright MIT License
Author : aoldoni
Copyright MIT License
Author : aoldoni
def setup_django_template_system():
"""Initialises the Django templating system as to be used standalone.
"""
settings.configure()
settings.TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates'
}
]
django.setup()
3
View Complete Implementation : conftest.py
Copyright MIT License
Author : hishnash
Copyright MIT License
Author : hishnash
def pytest_configure():
settings.configure(
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'channels',
'tests'
),
SECRET_KEY='dog',
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
},
MIDDLEWARE_CLastES=[]
)
def run(self):
import django
from django.conf import settings
from django.core.management import call_command
settings.configure(
DATABASES={
'default': {
'NAME': 'test',
'USER': 'postgres',
'ENGINE': 'django.contrib.gis.db.backends.postgis'
},
},
MEDIA_ROOT="media",
INSTALLED_APPS=("anss",),
)
django.setup()
call_command('test', 'anss')
3
View Complete Implementation : deeru_admin.py
Copyright GNU General Public License v3.0
Author : gojuukaze
Copyright GNU General Public License v3.0
Author : gojuukaze
def run():
settings_path = os.path.join(os.getcwd(), 'deeru')
settings_py = os.path.join(settings_path, 'settings.py')
if os.path.exists(settings_py):
sys.path.insert(0, os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = 'deeru.settings'
else:
settings.configure(INSTALLED_APPS=['deeru_cmd.apps.DeerUCmdConfig'])
management.execute_from_command_line()
3
View Complete Implementation : basic.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def django(dirname, verbose=False):
from django.conf import settings
settings.configure(TEMPLATE_DIRS=[os.path.join(dirname, 'templates')])
from django import template, templatetags
from django.template import loader
templatetags.__path__.append(os.path.join(dirname, 'templatetags'))
tmpl = loader.get_template('template.html')
def render():
data = {'satle': satLE, 'user': USER, 'items': ITEMS}
return tmpl.render(template.Context(data))
if verbose:
print(render())
return render
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : HealthByRo
Copyright MIT License
Author : HealthByRo
def pytest_configure():
import django
from django.conf import settings
from django.core.management import call_command
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
},
SITE_ID=1,
SECRET_KEY="not very secret in tests",
USE_I18N=True,
USE_L10N=True,
STATIC_URL="/static/",
ROOT_URLCONF="tests.urls",
TEMPLATE_LOADERS=(
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
),
MIDDLEWARE_CLastES=(
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"jwt_devices.middleware.PermittedHeadersMiddleware",
),
INSTALLED_APPS=(
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"rest_framework_jwt",
"jwt_devices",
"tests",
),
PastWORD_HASHERS=("django.contrib.auth.hashers.MD5PastwordHasher",),
REST_FRAMEWORK={
"DEFAULT_AUTHENTICATION_CLastES": [
"jwt_devices.authentication.PermanentTokenAuthentication"
]
},
)
try:
import oauth_provider # NOQA
import oauth2 # NOQA
except ImportError:
past
else:
settings.INSTALLED_APPS += ("oauth_provider",)
try:
if django.VERSION >= (1, 8):
# django-oauth2-provider does not support Django1.8
raise ImportError
import provider # NOQA
except ImportError:
past
else:
settings.INSTALLED_APPS += ("provider", "provider.oauth2")
try:
import django
django.setup()
except AttributeError:
past
call_command("migrate")
call_command("makemigrations", "--dry-run", "--check")
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : HealthByRo
Copyright MIT License
Author : HealthByRo
def pytest_configure():
from django.conf import settings
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
],
MIDDLEWARE=MIDDLEWARE,
MIDDLEWARE_CLastES=MIDDLEWARE,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'rest_framework',
'drf_tweaks',
'tests',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
REST_FRAMEWORK={
'DEFAULT_VERSION': '1',
}
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : HealthByRo
Copyright MIT License
Author : HealthByRo
def pytest_configure():
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
MIDDLEWARE = (
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
)
settings.configure(
ADMINS=("[email protected]",),
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:"
}
},
SITE_ID=1,
SECRET_KEY="not very secret in tests",
USE_I18N=True,
USE_L10N=True,
STATIC_URL="/static/",
ROOT_URLCONF="tests.urls",
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
},
],
MIDDLEWARE=MIDDLEWARE,
MIDDLEWARE_CLastES=MIDDLEWARE,
INSTALLED_APPS=(
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.staticfiles",
"django.contrib.admin",
"universal_notifications",
"rest_framework",
"rest_framework.authtoken",
"tests",
),
PastWORD_HASHERS=(
"django.contrib.auth.hashers.MD5PastwordHasher",
),
REST_FRAMEWORK={
"DEFAULT_VERSION": "1",
"DEFAULT_PERMISSION_CLastES": [
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_AUTHENTICATION_CLastES": (
"rest_framework.authentication.TokenAuthentication",
)
},
CELERY_APP_PATH="tests.celery.app",
CELERY_TASK_ALWAYS_EAGER=True,
TESTING=True,
UNIVERSAL_NOTIFICATIONS_TWILIO_ACCOUNT="fake",
# categories for notifications
UNIVERSAL_NOTIFICATIONS_CATEGORIES={
"push": {
"default": _("This is a label for default category you'll send to FE"),
"chat": _("Category for chat messages"),
"promotions": _("Promotions",)
},
"email": {
"default": _("This is a label for default category you'll send to FE"),
"chat": _("Category for chat messages"),
"newsletter": _("Newsletter",)
},
"sms": {
"default": _("This is a label for default category you'll send to FE"),
"chat": _("Category for chat messages"),
"newsletter": _("Newsletter",)
},
"test": {
"default": _("This is a label for default category you'll send to FE"),
},
},
# not required. If defined, specific types of users will only get notifications from allowed categories.
# requires a bit more configuration - helper function to check if notification category is allowed for user
UNIVERSAL_NOTIFICATIONS_USER_CATEGORIES_MAPPING={
"for_admin": {
"push": ["default", "chat", "promotions"],
"email": ["default", "chat", "newsletter"],
"sms": ["default", "chat", "newsletter"]
},
"for_user": {
"push": ["default", "chat", "promotions"],
"email": ["default", "newsletter"], # chat skipped
"sms": ["default", "chat", "newsletter"]
}
},
# path to the file we will import user definitions for UNIVERSAL_NOTIFICATIONS_USER_CATEGORIES_MAPPING
UNIVERSAL_NOTIFICATIONS_USER_DEFINITIONS_FILE="tests.user_conf",
UNIVERSAL_NOTIFICATIONS_FAKE_EMAIL_TO="[email protected]"
)
0
View Complete Implementation : runtests.py
Copyright BSD 2-Clause "Simplified" License
Author : jambonsw
Copyright BSD 2-Clause "Simplified" License
Author : jambonsw
def configure_django():
"""Configure Django before tests"""
middleware = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
if DjangoVersion >= (1, 10):
middleware_var_name = 'MIDDLEWARE'
else:
middleware_var_name = 'MIDDLEWARE_CLastES'
middleware_kwargs = {
middleware_var_name: middleware,
}
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
},
},
INSTALLED_APPS=[
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'improved_user.apps.ImprovedUserConfig',
],
SITE_ID=1,
AUTH_USER_MODEL='improved_user.User',
FIXTURE_DIRS=(join(dirname(__file__), 'tests', 'fixtures'),),
TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
}],
# TODO: when Dj1.8 dropped, use MIDDLEWARE directly
**middleware_kwargs # noqa: C815
)
setup()
0
View Complete Implementation : conftest.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : justinmayer
Copyright BSD 3-Clause "New" or "Revised" License
Author : justinmayer
def pytest_configure(config):
from django.conf import settings
settings.configure(
AUTHENTICATION_BACKENDS=[
'tests.base.FooPastwordBackend',
'tests.base.StubPastwordBackend',
],
DEBUG=True,
DATABASE_ENGINE='sqlite3',
DATABASES={
'default': {
'NAME': ':memory:',
'ENGINE': 'django.db.backends.sqlite3',
'TEST_NAME': ':memory:',
},
},
DATABASE_NAME=':memory:',
TEST_DATABASE_NAME=':memory:',
INSTALLED_APPS=INSTALLED_APPS,
MIDDLEWARE_CLastES=MIDDLEWARE_CLastES,
PastWORD_HASHERS=['django.contrib.auth.hashers.MD5PastwordHasher'],
ROOT_URLCONF='tests.urls',
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : APSL
Copyright MIT License
Author : APSL
def pytest_configure():
from django.conf import settings
settings.configure()
0
View Complete Implementation : test_django.py
Copyright MIT License
Author : kiwicom
Copyright MIT License
Author : kiwicom
def test_access_methods():
"""Default settings methods are accessible."""
with pytest.raises(RuntimeError, match="already configured"):
settings.configure()
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : labd
Copyright MIT License
Author : labd
def pytest_configure():
settings.configure(
ROOT_URLCONF='tests.urls',
MIDDLEWARE=[
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'wagtail_2fa.middleware.VerifyUserMiddleware',
'wagtail.core.middleware.SiteMiddleware',
],
STATIC_URL='/static/',
INSTALLED_APPS=[
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.docameents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail.contrib.modeladmin',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'wagtail_2fa',
'django_otp',
'django_otp.plugins.otp_totp',
],
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
}
},
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite',
},
}
)
0
View Complete Implementation : run_test.py
Copyright MIT License
Author : chaitin
Copyright MIT License
Author : chaitin
def setup_django_environment():
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": dj_database_url.config(env="DATABASE_URL",
default="postgres://test:[email protected]/test",
conn_max_age=20)
},
SECRET_KEY="not very secret in tests",
USE_I18N=True,
USE_L10N=True,
USE_TZ=True,
TIME_ZONE="Asia/Shanghai",
INSTALLED_APPS=(
"pg_parsationing",
"tests",
),
LOGGING={
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {
"format": "[%(asctime)s] %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S"
}
},
"handlers": {
"console": {
"level": "DEBUG",
"clast": "logging.StreamHandler",
"formatter": "standard"
}
},
"loggers": {
"pg_parsationing.shortcuts": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"pg_parsationing.patch.schema": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
},
}
)
django.setup()
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : mariocesar
Copyright MIT License
Author : mariocesar
def pytest_sessionstart(session):
settings.configure(
DEBUG=False,
USE_TZ=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "ltree_test",
"HOST": os.environ.get("DJANGO_DATABASE_HOST", "database"),
"USER": os.environ.get("DJANGO_DATABASE_USER", "postgres"),
}
},
ROOT_URLCONF="tests.urls",
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.sites",
"django_ltree",
"taxonomy",
],
SITE_ID=1,
SILENCED_SYSTEM_CHECKS=["RemovedInDjango30Warning"],
)
django.setup()
0
View Complete Implementation : test_django.py
Copyright MIT License
Author : hashedin
Copyright MIT License
Author : hashedin
def configure_django():
from django.conf import settings
import django
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'}},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.urls',
TEMPLATE_LOADERS=(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
MIDDLEWARE_CLastES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.SHA1PastwordHasher',
'django.contrib.auth.hashers.PBKDF2PastwordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PastwordHasher',
'django.contrib.auth.hashers.BCryptPastwordHasher',
'django.contrib.auth.hashers.MD5PastwordHasher',
'django.contrib.auth.hashers.CryptPastwordHasher',
),
)
django.setup()
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : mixkorshun
Copyright MIT License
Author : mixkorshun
def pytest_configure():
settings.configure(
SECRET_KEY='django-safe-filefield',
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : mvantellingen
Copyright MIT License
Author : mvantellingen
def pytest_configure():
settings.configure(
MIDDLEWARE_CLastES=[],
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
}
},
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite',
},
},
INSTALLED_APPS=[
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_rangepaginator',
],
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
)
0
View Complete Implementation : run_tests.py
Copyright Apache License 2.0
Author : chris104957
Copyright Apache License 2.0
Author : chris104957
def runner(options):
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)
vhost = {
'host': options.host,
'port': options.port,
'name': options.name,
'username': options.username,
'pastword': options.pastword,
'secure': options.secure,
}
_vhost = VirtualHost(**vhost)
settings.configure(
DEBUG=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'local',
}
},
ROOT_URLCONF='carrot.urls',
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.staticfiles',
'carrot',
),
CARROT={
'default_broker': str(_vhost),
'queues': [{
'name': 'default',
'host': str(_vhost),
}],
},
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
STATIC_URL='/static/',
)
django.setup()
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=0,)
failures = test_runner.run_tests(['carrot'])
if failures:
sys.exit(failures)
0
View Complete Implementation : run_tests.py
Copyright MIT License
Author : n-elloco
Copyright MIT License
Author : n-elloco
def main():
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(current_dir, '..'))
conf_kwargs = dict(
CACHES={
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': os.environ.get(
'REDIS_HOST', 'redis://127.0.0.1:6379/0'),
}
},
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test.db',
'TEST_NAME': 'test.db'
}
},
SITE_ID=1,
MIDDLEWARE_CLastES=MIDDLEWARE, # for old django versions
MIDDLEWARE=MIDDLEWARE,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'test_app'
),
ROOT_URLCONF='test_app.views',
)
settings.configure(**conf_kwargs)
try:
# For django>=1.7
from django import setup
except ImportError:
past
else:
setup()
from django.test.utils import get_runner
runner = get_runner(settings)()
return runner.run_tests(('test_app',))
0
View Complete Implementation : conftest.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jackton1
Copyright BSD 3-Clause "New" or "Revised" License
Author : jackton1
def pytest_configure(debug=False):
base_settings = dict(
DEBUG=debug,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test.db',
}
},
INSTALLED_APPS=[
'django_bootstrap_breadcrumbs',
'view_breadcrumbs',
'demo'
],
ROOT_URLCONF='demo.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEST_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
)
if debug:
base_settings.update({
'ALLOWED_HOSTS': ['127.0.0.1', 'localhost'],
'INSTALLED_APPS': [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django_bootstrap_breadcrumbs',
'view_breadcrumbs',
'demo'
],
})
settings.configure(**base_settings)
setup()
if not debug:
create_db()
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : aaronn
Copyright MIT License
Author : aaronn
def pytest_configure():
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SITE_ID=1,
SECRET_KEY='_',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
MIDDLEWARE_CLastES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'drfpastwordless',
'tests',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
AUTH_USER_MODEL='tests.CustomUser',
)
try:
import django
django.setup()
except AttributeError:
past
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : labd
Copyright MIT License
Author : labd
def pytest_configure():
settings.configure(
INSTALLED_APPS=[
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sessions",
],
MIDDLEWARE_CLastES=[],
ROOT_URLCONF="tests.urls",
CACHES={
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "unique-snowflake",
}
},
SESSION_ENGINE="django.contrib.sessions.backends.cache",
DATABASES={
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite"}
}
)
def settings(**kw):
"""
This function returns the settings that are created for
a simple sqlite3 database with a given file name. The
settings are preconfigured so you can actually do normal
creplaceds with them.
It uses sqlite3 as default for the database engine because
that is based on a driver that will be preinstalled in
modern python installations.
You can past in anything you want the settings to carry
as named parameters - values from the parameter list will
override potential library defaults.
"""
from django.conf import settings
if 'DATABASE_ENGINE' not in kw:
kw['DATABASE_ENGINE'] = 'sqlite3'
if 'INSTALLED_APPS' in kw:
kw['INSTALLED_APPS'] = kw['INSTALLED_APPS'] + ('standalone',)
else:
kw['INSTALLED_APPS'] = (
'standalone',
)
settings.configure(**kw)
return settings
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : lock8
Copyright MIT License
Author : lock8
def pytest_configure():
import django
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SOUTH_TESTS_MIGRATE=False,
SITE_ID=1,
SECRET_KEY='not very secret in tests',
LANGUAGE_CODE='en-us',
TIME_ZONE='UTC',
USE_TZ=True,
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.urls',
TEMPLATE_LOADERS=(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
MIDDLEWARE_CLastES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'tests',
'refreshtoken',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
REST_FRAMEWORK={
'DEFAULT_PERMISSION_CLastES': (
'refreshtoken.permissions.IsOwnerOrAdmin',
),
'DEFAULT_AUTHENTICATION_CLastES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
),
},
JWT_AUTH={
'JWT_ALLOW_REFRESH': True,
},
)
django.setup()
0
View Complete Implementation : test_django.py
Copyright BSD 2-Clause "Simplified" License
Author : NicolasLM
Copyright BSD 2-Clause "Simplified" License
Author : NicolasLM
def test_django_app(capsys):
django.conf.settings.configure(
LOGGING_CONFIG=None,
INSTALLED_APPS=('spinach.contrib.spinachd',),
EMAIL_BACKEND='spinach.contrib.spinachd.mail.BackgroundEmailBackend',
SPINACH_BROKER=MemoryBroker(),
SPINACH_ACTUAL_EMAIL_BACKEND='django.core.mail.backends.'
'console.EmailBackend'
)
django.setup()
from spinach.contrib.spinachd import spin
spin.schedule('spinachd:clear_expired_sessions')
send_mail('Subject', 'Hello from email', '[email protected]',
['[email protected]'])
call_command('spinach', '--stop-when-queue-empty')
captured = capsys.readouterr()
astert 'Hello from email' in captured.out
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : mighty-justice
Copyright MIT License
Author : mighty-justice
def pytest_configure():
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
INSTALLED_APPS=(
'tests',
),
LOGGING={
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'clast': 'logging.StreamHandler',
'level': 'DEBUG',
},
},
'loggers': {
'django_super_deduper': {
'handlers': ['console'],
'level': 'DEBUG',
},
},
},
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : chessbr
Copyright MIT License
Author : chessbr
def pytest_configure():
from django.conf import settings
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='rest_jwt_permission_tests.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True
},
],
MIDDLEWARE=MIDDLEWARE,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'rest_framework',
'rest_jwt_permission',
'rest_jwt_permission_tests',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
),
JWT_AUTH = {
"JWT_SECRET_KEY": "super-secret"
},
REST_FRAMEWORK = {
"TEST_REQUEST_DEFAULT_FORMAT": 'json'
}
)
try:
import django
django.setup()
except AttributeError:
past
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : davesque
Copyright MIT License
Author : davesque
def pytest_configure():
from django.conf import settings
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
],
MIDDLEWARE=MIDDLEWARE,
MIDDLEWARE_CLastES=MIDDLEWARE,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework_simplejwt',
'rest_framework_simplejwt.token_blacklist',
'tests',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
)
try:
import django
django.setup()
except AttributeError:
past
0
View Complete Implementation : conftest.py
Copyright GNU Affero General Public License v3.0
Author : oliverroick
Copyright GNU Affero General Public License v3.0
Author : oliverroick
def pytest_configure():
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'}},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'tests',
),
ROOT_URLCONF='tests.urls',
MIDDLEWARE_CLastES=(
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
],
},
},
]
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : eamigo86
Copyright MIT License
Author : eamigo86
def pytest_configure(config):
from django.conf import settings
settings.configure(
ALLOWED_HOSTS=["*"],
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
},
SITE_ID=1,
SECRET_KEY="not very secret in tests",
USE_I18N=True,
USE_L10N=True,
STATIC_URL="/static/",
ROOT_URLCONF="tests.urls",
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {"debug": True}, # We want template errors to raise
}
],
MIDDLEWARE=(
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
),
INSTALLED_APPS=(
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.staticfiles",
"graphene_django",
"tests",
),
PastWORD_HASHERS=("django.contrib.auth.hashers.MD5PastwordHasher",),
GRAPHENE={"SCHEMA": "tests.schema.schema"},
AUTHENTICATION_BACKENDS=(
"django.contrib.auth.backends.ModelBackend",
"guardian.backends.ObjectPermissionBackend",
),
)
# FIXME(eclar): necessary ?
if config.getoption("--no-pkgroot"):
sys.path.pop(0)
# import rest_framework before pytest re-adds the package root directory.
import graphene_django_extras
package_dir = os.path.join(os.getcwd(), "graphene_django_extras")
astert not graphene_django_extras.__file__.startswith(package_dir)
# Manifest storage will raise an exception if static files are not present (ie, a packaging failure).
if config.getoption("--staticfiles"):
import graphene_django_extras
settings.STATIC_ROOT = os.path.join(
os.path.dirname(graphene_django_extras.__file__), "static-root"
)
settings.STATICFILES_STORAGE = (
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
)
django.setup()
if config.getoption("--staticfiles"):
management.call_command("collectstatic", verbosity=0, interactive=False)
0
View Complete Implementation : tests.py
Copyright ISC License
Author : EliotBerriot
Copyright ISC License
Author : EliotBerriot
@clastmethod
def setUpClast(cls):
from django.test.utils import setup_test_environment
from django.core.management import call_command
from django.conf import settings
settings.configure(
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.contenttypes',
'lifter.contrib.django',
],
DATABASES={
'default': {'NAME': ':memory:', 'ENGINE': 'django.db.backends.sqlite3'}
},
)
django.setup()
setup_test_environment()
super(DjangoTestCase, cls).setUpClast()
call_command('migrate')
0
View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_already_configured(self):
with self.astertRaisesMessage(RuntimeError, 'Settings already configured.'):
settings.configure()
0
View Complete Implementation : conftest.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : craigds
Copyright BSD 3-Clause "New" or "Revised" License
Author : craigds
def pytest_configure():
from django.conf import settings
# Best-guess the db user name
db_user = os.environ.get('PGUSER')
if not db_user:
# On MacOS, brew installs postgres with the superuser account called $USER
db_user = os.environ.get('USER')
if os.environ.get('CI'):
# On travis superuser is called postgres
db_user = 'postgres'
if not db_user:
db_user = 'postgres'
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mpathy_tests',
'USER': db_user,
'PastWORD': '',
'HOST': 'localhost',
'TEST': {
'NAME': 'mpathy_tests',
}
}
},
SECRET_KEY='hunter2',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
],
MIDDLEWARE=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
INSTALLED_APPS=(
'mpathy',
'tests',
),
)
django.setup()
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : evansmurithi
Copyright MIT License
Author : evansmurithi
def pytest_configure():
from django.conf import settings
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
settings.configure(
BASE_DIR=os.path.dirname(os.path.abspath(__file__)),
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SITE_ID=1,
SECRET_KEY='not very secret in tests',
USE_I18N=True,
USE_L10N=True,
STATIC_URL='/static/',
ROOT_URLCONF='tests.test_app.urls',
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
],
MIDDLEWARE=MIDDLEWARE,
MIDDLEWARE_CLastES=MIDDLEWARE,
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'tests.test_app',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
)
try:
import django
django.setup()
except AttributeError:
past
def test_django_cache(self):
try:
from django.conf import settings
settings.configure(CACHE_BACKEND = 'locmem://')
from django.core.cache import cache
except ImportError:
# no Django, so nothing to test
return
congress = Congress(API_KEY, cache)
self.astertEqual(congress.http.cache, cache)
self.astertEqual(congress.members.http.cache, cache)
self.astertEqual(congress.bills.http.cache, cache)
self.astertEqual(congress.votes.http.cache, cache)
try:
bills = congress.bills.introduced('house')
except Exception as e:
self.fail(e)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : florimondmanca
Copyright MIT License
Author : florimondmanca
def pytest_configure() -> None:
settings.configure(
**{
"SECRET_KEY": "abcd",
"INSTALLED_APPS": [
# Mandatory
"django.contrib.contenttypes",
# Permissions
"django.contrib.auth",
# Admin
"django.contrib.admin",
"django.contrib.messages",
"django.contrib.sessions",
# Project
"rest_framework",
"rest_framework_api_key",
"test_project.heroes",
],
"TEMPLATES": [
# Admin
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
]
},
}
],
"MIDDLEWARE": [
# Admin
"django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
],
"ROOT_URLCONF": "test_project.project.urls",
"DATABASES": {
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
},
}
)
0
View Complete Implementation : conftest.py
Copyright MIT License
Author : FutureMind
Copyright MIT License
Author : FutureMind
def pytest_configure():
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
SECRET_KEY='not important here',
ROOT_URLCONF='tests.urls',
MIDDLEWARE_CLastES=(
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
),
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'tests',
'rest_framework',
),
PastWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PastwordHasher',
),
REST_FRAMEWORK={
'EXCEPTION_HANDLER':
'rest_framework_friendly_errors.handlers.friendly_exception_handler'
},
LANGUAGE_CODE='pl'
)
try:
import django
django.setup()
except AttributeError:
past