22import sys
33from os .path import abspath , dirname , join
44
5- from tests .fixtures import (elasticapm_client , instrument , not_so_random ,
6- sending_elasticapm_client , validating_httpserver ,
7- waiting_httpserver , waiting_httpsserver )
5+ from tests .fixtures import (
6+ elasticapm_client ,
7+ instrument ,
8+ not_so_random ,
9+ sending_elasticapm_client ,
10+ validating_httpserver ,
11+ waiting_httpserver ,
12+ waiting_httpsserver ,
13+ )
814from tests .utils .compat import middleware_setting
915
1016try :
1925
2026where_am_i = dirname (abspath (__file__ ))
2127
22- BASE_TEMPLATE_DIR = join (where_am_i , 'tests' , 'contrib' , 'django' , 'testapp' ,
23- 'templates' )
28+ BASE_TEMPLATE_DIR = join (where_am_i , "tests" , "contrib" , "django" , "testapp" , "templates" )
2429
2530sys .path .insert (0 , where_am_i )
2631
2732# don't run tests of dependencies that land in "build" and "src"
28- collect_ignore = [' build' , ' src' ]
33+ collect_ignore = [" build" , " src" ]
2934
3035
3136try :
3237 from psycopg2cffi import compat
38+
3339 compat .register ()
3440except ImportError :
3541 pass
@@ -42,32 +48,29 @@ def pytest_configure(config):
4248 settings = None
4349 if settings is not None and not settings .configured :
4450 import django
51+
4552 settings_dict = dict (
46- SECRET_KEY = '42' ,
53+ SECRET_KEY = "42" ,
4754 DATABASES = {
48- 'default' : {
49- 'ENGINE' : 'django.db.backends.sqlite3' ,
50- 'NAME' : 'elasticapm_tests.db' ,
51- 'TEST_NAME' : 'elasticapm_tests.db' ,
52- 'TEST' : {
53- 'NAME' : 'elasticapm_tests.db' ,
54- }
55- },
55+ "default" : {
56+ "ENGINE" : "django.db.backends.sqlite3" ,
57+ "NAME" : "elasticapm_tests.db" ,
58+ "TEST_NAME" : "elasticapm_tests.db" ,
59+ "TEST" : {"NAME" : "elasticapm_tests.db" },
60+ }
5661 },
57- TEST_DATABASE_NAME = ' elasticapm_tests.db' ,
62+ TEST_DATABASE_NAME = " elasticapm_tests.db" ,
5863 INSTALLED_APPS = [
59- 'django.contrib.auth' ,
60- 'django.contrib.admin' ,
61- 'django.contrib.sessions' ,
62- 'django.contrib.sites' ,
63- 'django.contrib.redirects' ,
64-
65- 'django.contrib.contenttypes' ,
66-
67- 'elasticapm.contrib.django' ,
68- 'tests.contrib.django.testapp' ,
64+ "django.contrib.auth" ,
65+ "django.contrib.admin" ,
66+ "django.contrib.sessions" ,
67+ "django.contrib.sites" ,
68+ "django.contrib.redirects" ,
69+ "django.contrib.contenttypes" ,
70+ "elasticapm.contrib.django" ,
71+ "tests.contrib.django.testapp" ,
6972 ],
70- ROOT_URLCONF = ' tests.contrib.django.testapp.urls' ,
73+ ROOT_URLCONF = " tests.contrib.django.testapp.urls" ,
7174 DEBUG = False ,
7275 SITE_ID = 1 ,
7376 BROKER_HOST = "localhost" ,
@@ -78,28 +81,29 @@ def pytest_configure(config):
7881 CELERY_ALWAYS_EAGER = True ,
7982 TEMPLATE_DEBUG = False ,
8083 TEMPLATE_DIRS = [BASE_TEMPLATE_DIR ],
81- ALLOWED_HOSTS = ['*' ],
84+ ALLOWED_HOSTS = ["*" ],
8285 TEMPLATES = [
8386 {
84- 'BACKEND' : 'django.template.backends.django.DjangoTemplates' ,
85- 'DIRS' : [BASE_TEMPLATE_DIR ],
86- 'OPTIONS' : {
87- 'context_processors' : [
88- 'django.contrib.auth.context_processors.auth' ,
89- ],
90- 'loaders' : [
91- 'django.template.loaders.filesystem.Loader' ,
92- ],
93- 'debug' : False ,
87+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
88+ "DIRS" : [BASE_TEMPLATE_DIR ],
89+ "OPTIONS" : {
90+ "context_processors" : ["django.contrib.auth.context_processors.auth" ],
91+ "loaders" : ["django.template.loaders.filesystem.Loader" ],
92+ "debug" : False ,
9493 },
95- },
96- ]
94+ }
95+ ],
96+ )
97+ settings_dict .update (
98+ ** middleware_setting (
99+ django .VERSION ,
100+ [
101+ "django.contrib.sessions.middleware.SessionMiddleware" ,
102+ "django.contrib.auth.middleware.AuthenticationMiddleware" ,
103+ "django.contrib.messages.middleware.MessageMiddleware" ,
104+ ],
105+ )
97106 )
98- settings_dict .update (** middleware_setting (django .VERSION , [
99- 'django.contrib.sessions.middleware.SessionMiddleware' ,
100- 'django.contrib.auth.middleware.AuthenticationMiddleware' ,
101- 'django.contrib.messages.middleware.MessageMiddleware' ,
102- ]))
103107 settings .configure (** settings_dict )
104- if hasattr (django , ' setup' ):
108+ if hasattr (django , " setup" ):
105109 django .setup ()
0 commit comments