This repository was archived by the owner on Oct 13, 2021. It is now read-only.
File tree 6 files changed +40
-28
lines changed
6 files changed +40
-28
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ import django
3
+ from django .conf import settings
4
+
5
+ # We manually designate which settings we will be using in an environment variable
6
+ # This is similar to what occurs in the `manage.py`
7
+ os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'tests.contrib.django.app.settings' )
8
+
9
+
10
+ # `pytest` automatically calls this function once when tests are run.
11
+ def pytest_configure ():
12
+ settings .DEBUG = False
13
+ if django .VERSION < (1 , 7 , 0 ):
14
+ settings .configure ()
15
+ else :
16
+ django .setup ()
Original file line number Diff line number Diff line change 21
21
USE_I18N = True
22
22
USE_L10N = True
23
23
STATIC_URL = '/static/'
24
- ROOT_URLCONF = 'app.views'
24
+ ROOT_URLCONF = 'tests.contrib.djangorestframework. app.views'
25
25
26
26
TEMPLATES = [
27
27
{
111
111
'rest_framework.permissions.IsAdminUser' ,
112
112
],
113
113
114
- 'EXCEPTION_HANDLER' : 'app.exceptions.custom_exception_handler'
114
+ 'EXCEPTION_HANDLER' : 'tests.contrib.djangorestframework. app.exceptions.custom_exception_handler'
115
115
}
Original file line number Diff line number Diff line change
1
+ import os
2
+ import django
3
+ from django .conf import settings
4
+
5
+ # We manually designate which settings we will be using in an environment variable
6
+ # This is similar to what occurs in the `manage.py`
7
+ os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'tests.contrib.djangorestframework.app.settings' )
8
+
9
+
10
+ # `pytest` automatically calls this function once when tests are run.
11
+ def pytest_configure ():
12
+ settings .DEBUG = False
13
+ if django .VERSION < (1 , 7 , 0 ):
14
+ settings .configure ()
15
+ else :
16
+ django .setup ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ def test_unpatch(self):
35
35
assert len (spans ) == 1
36
36
sp = spans [0 ]
37
37
assert sp .name == 'django.request'
38
- assert sp .resource == 'app.views.UserViewSet'
38
+ assert sp .resource == 'tests.contrib.djangorestframework. app.views.UserViewSet'
39
39
assert sp .error == 0
40
40
assert sp .span_type == 'http'
41
41
assert sp .get_tag ('http.status_code' ) == '500'
@@ -52,7 +52,7 @@ def test_trace_exceptions(self):
52
52
assert len (spans ) == 1
53
53
sp = spans [0 ]
54
54
assert sp .name == 'django.request'
55
- assert sp .resource == 'app.views.UserViewSet'
55
+ assert sp .resource == 'tests.contrib.djangorestframework. app.views.UserViewSet'
56
56
assert sp .error == 1
57
57
assert sp .span_type == 'http'
58
58
assert sp .get_tag ('http.method' ) == 'GET'
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ deps =
138
138
pytest>=3
139
139
pytest-benchmark
140
140
pytest-cov
141
+ pytest-django
141
142
opentracing
142
143
psutil
143
144
# test dependencies installed in all envs
@@ -378,9 +379,9 @@ commands =
378
379
cassandra_contrib: pytest {posargs} tests/contrib/cassandra
379
380
celery_contrib: pytest {posargs} tests/contrib/celery
380
381
dbapi_contrib: pytest {posargs} tests/contrib/dbapi
381
- django_contrib: python tests/contrib/django/runtests.py {posargs}
382
- django_contrib_autopatch: python tests/ddtrace_run.py python tests/contrib/django/runtests.py {posargs}
383
- django_drf_contrib: python tests/contrib/djangorestframework/runtests.py {posargs}
382
+ django_contrib: pytest {posargs} tests/contrib/django
383
+ django_contrib_autopatch: python tests/ddtrace_run.py pytest {posargs} tests/contrib/django
384
+ django_drf_contrib: pytest {posargs} tests/contrib/djangorestframework
384
385
elasticsearch_contrib: pytest {posargs} tests/contrib/elasticsearch
385
386
falcon_contrib: pytest {posargs} tests/contrib/falcon/test_middleware.py tests/contrib/falcon/test_distributed_tracing.py
386
387
falcon_contrib_autopatch: python tests/ddtrace_run.py pytest {posargs} tests/contrib/falcon/test_autopatch.py
@@ -423,9 +424,6 @@ commands =
423
424
unit_tests: pytest {posargs} tests/unit
424
425
benchmarks: pytest --benchmark-only {posargs} tests/benchmark.py
425
426
426
- setenv =
427
- DJANGO_SETTINGS_MODULE = app.settings
428
-
429
427
[testenv:wait]
430
428
commands =python tests/wait-for-services.py {posargs}
431
429
basepython =python
You can’t perform that action at this time.
0 commit comments