Skip to content

Commit 2383dc2

Browse files
authored
Add Django 4.2 LTS and Django 5.0 to test matrix (#1985)
* ci: add Django 4.2 LTS and Django 5.0 to test matrix Closes #1946 * tests: remove django tests for old and not tested versions
1 parent 49b4727 commit 2383dc2

File tree

7 files changed

+39
-69
lines changed

7 files changed

+39
-69
lines changed

.ci/.matrix_exclude.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,34 @@ exclude:
99
FRAMEWORK: django-4.0
1010
- VERSION: python-3.7
1111
FRAMEWORK: django-4.0
12+
# Django 4.2 requires Python 3.8+
13+
- VERSION: python-3.6
14+
FRAMEWORK: django-4.2
15+
- VERSION: python-3.7
16+
FRAMEWORK: django-4.2
17+
# Django 5.0 requires Python 3.10+
18+
- VERSION: python-3.6
19+
FRAMEWORK: django-5.0
20+
- VERSION: python-3.7
21+
FRAMEWORK: django-5.0
22+
- VERSION: python-3.8
23+
FRAMEWORK: django-5.0
24+
- VERSION: python-3.9
25+
FRAMEWORK: django-5.0
1226
- VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7
1327
FRAMEWORK: celery-5-django-4
1428
- VERSION: python-3.6
1529
FRAMEWORK: celery-5-django-4
1630
- VERSION: python-3.7
1731
FRAMEWORK: celery-5-django-4
32+
- VERSION: python-3.6
33+
FRAMEWORK: celery-5-django-5
34+
- VERSION: python-3.7
35+
FRAMEWORK: celery-5-django-5
36+
- VERSION: python-3.8
37+
FRAMEWORK: celery-5-django-5
38+
- VERSION: python-3.9
39+
FRAMEWORK: celery-5-django-5
1840
# Flask
1941
- VERSION: pypy-3
2042
FRAMEWORK: flask-0.11 # see https://github.com/pallets/flask/commit/6e46d0cd, 0.11.2 was never released

.ci/.matrix_framework.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
FRAMEWORK:
44
- none
55
- django-1.11
6-
- django-2.0
7-
- django-3.1
86
- django-3.2
97
- django-4.0
8+
- django-4.2
9+
- django-5.0
1010
- flask-0.12
1111
- flask-1.1
1212
- flask-2.0
@@ -18,6 +18,7 @@ FRAMEWORK:
1818
- celery-4-django-2.0
1919
- celery-5-flask-2
2020
- celery-5-django-4
21+
- celery-5-django-5
2122
- requests-newest
2223
- boto3-newest
2324
- pymongo-newest

.ci/.matrix_framework_full.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ FRAMEWORK:
1010
- django-3.1
1111
- django-3.2
1212
- django-4.0
13+
- django-4.2
14+
- django-5.0
1315
# - django-master
1416
- flask-0.10
1517
- flask-0.11
@@ -25,6 +27,7 @@ FRAMEWORK:
2527
- celery-5-flask-2
2628
- celery-5-django-3
2729
- celery-5-django-4
30+
- celery-5-django-5
2831
- opentelemetry-newest
2932
- opentracing-newest
3033
- opentracing-2.0

tests/contrib/django/django_tests.py

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -270,25 +270,7 @@ def test_user_info_with_custom_user_non_string_username(django_elasticapm_client
270270
assert user_info["username"] == "1"
271271

272272

273-
@pytest.mark.skipif(django.VERSION > (1, 9), reason="MIDDLEWARE_CLASSES removed in Django 2.0")
274273
def test_user_info_with_non_django_auth(django_elasticapm_client, client):
275-
with override_settings(
276-
INSTALLED_APPS=[app for app in settings.INSTALLED_APPS if app != "django.contrib.auth"]
277-
) and override_settings(
278-
MIDDLEWARE_CLASSES=[
279-
m for m in settings.MIDDLEWARE_CLASSES if m != "django.contrib.auth.middleware.AuthenticationMiddleware"
280-
]
281-
):
282-
with pytest.raises(Exception):
283-
resp = client.get(reverse("elasticapm-raise-exc"))
284-
285-
assert len(django_elasticapm_client.events[ERROR]) == 1
286-
event = django_elasticapm_client.events[ERROR][0]
287-
assert event["context"]["user"] == {}
288-
289-
290-
@pytest.mark.skipif(django.VERSION < (1, 10), reason="MIDDLEWARE new in Django 1.10")
291-
def test_user_info_with_non_django_auth_django_2(django_elasticapm_client, client):
292274
with override_settings(
293275
INSTALLED_APPS=[app for app in settings.INSTALLED_APPS if app != "django.contrib.auth"]
294276
) and override_settings(
@@ -303,22 +285,7 @@ def test_user_info_with_non_django_auth_django_2(django_elasticapm_client, clien
303285
assert event["context"]["user"] == {}
304286

305287

306-
@pytest.mark.skipif(django.VERSION > (1, 9), reason="MIDDLEWARE_CLASSES removed in Django 2.0")
307288
def test_user_info_without_auth_middleware(django_elasticapm_client, client):
308-
with override_settings(
309-
MIDDLEWARE_CLASSES=[
310-
m for m in settings.MIDDLEWARE_CLASSES if m != "django.contrib.auth.middleware.AuthenticationMiddleware"
311-
]
312-
):
313-
with pytest.raises(Exception):
314-
client.get(reverse("elasticapm-raise-exc"))
315-
assert len(django_elasticapm_client.events[ERROR]) == 1
316-
event = django_elasticapm_client.events[ERROR][0]
317-
assert event["context"]["user"] == {}
318-
319-
320-
@pytest.mark.skipif(django.VERSION < (1, 10), reason="MIDDLEWARE new in Django 1.10")
321-
def test_user_info_without_auth_middleware_django_2(django_elasticapm_client, client):
322289
with override_settings(
323290
MIDDLEWARE_CLASSES=None,
324291
MIDDLEWARE=[m for m in settings.MIDDLEWARE if m != "django.contrib.auth.middleware.AuthenticationMiddleware"],
@@ -614,8 +581,7 @@ def read():
614581
assert_any_record_contains(caplog.records, "Can't capture request body: foobar")
615582

616583

617-
@pytest.mark.skipif(django.VERSION < (1, 9), reason="get-raw-uri-not-available")
618-
def test_disallowed_hosts_error_django_19(django_elasticapm_client):
584+
def test_disallowed_hosts_error(django_elasticapm_client):
619585
request = WSGIRequest(
620586
environ={
621587
"wsgi.input": io.BytesIO(),
@@ -634,26 +600,6 @@ def test_disallowed_hosts_error_django_19(django_elasticapm_client):
634600
assert event["context"]["request"]["url"]["full"] == "http://testserver/"
635601

636602

637-
@pytest.mark.skipif(django.VERSION >= (1, 9), reason="get-raw-uri-available")
638-
def test_disallowed_hosts_error_django_18(django_elasticapm_client):
639-
request = WSGIRequest(
640-
environ={
641-
"wsgi.input": io.BytesIO(),
642-
"wsgi.url_scheme": "http",
643-
"REQUEST_METHOD": "POST",
644-
"SERVER_NAME": "testserver",
645-
"SERVER_PORT": "80",
646-
"CONTENT_TYPE": "application/json",
647-
"ACCEPT": "application/json",
648-
}
649-
)
650-
with override_settings(ALLOWED_HOSTS=["example.com"]):
651-
# this should not raise a DisallowedHost exception
652-
django_elasticapm_client.capture("Message", message="foo", request=request)
653-
event = django_elasticapm_client.events[ERROR][0]
654-
assert event["context"]["request"]["url"] == {"full": "DisallowedHost"}
655-
656-
657603
@pytest.mark.parametrize(
658604
"django_elasticapm_client",
659605
[{"capture_body": "errors"}, {"capture_body": "all"}, {"capture_body": "off"}],
@@ -1196,16 +1142,6 @@ def test_stacktrace_filtered_for_elasticapm(client, django_elasticapm_client):
11961142
assert spans[1]["stacktrace"][0]["module"].startswith("django.template"), spans[1]["stacktrace"][0]["function"]
11971143

11981144

1199-
@pytest.mark.skipif(django.VERSION > (1, 7), reason="argparse raises CommandError in this case")
1200-
@mock.patch("elasticapm.contrib.django.management.commands.elasticapm.Command._get_argv")
1201-
def test_subcommand_not_set(argv_mock):
1202-
stdout = io.StringIO()
1203-
argv_mock.return_value = ["manage.py", "elasticapm"]
1204-
call_command("elasticapm", stdout=stdout)
1205-
output = stdout.getvalue()
1206-
assert "No command specified" in output
1207-
1208-
12091145
@mock.patch("elasticapm.contrib.django.management.commands.elasticapm.Command._get_argv")
12101146
def test_subcommand_not_known(argv_mock):
12111147
stdout = io.StringIO()
@@ -1317,8 +1253,8 @@ def test_settings_server_url_with_credentials():
13171253

13181254

13191255
@pytest.mark.skipif(
1320-
not ((1, 10) <= django.VERSION < (2, 0)),
1321-
reason="only needed in 1.10 and 1.11 when both middleware settings are valid",
1256+
django.VERSION >= (2, 0),
1257+
reason="only needed in 1.11 when both middleware settings are valid",
13221258
)
13231259
def test_django_1_10_uses_deprecated_MIDDLEWARE_CLASSES():
13241260
stdout = io.StringIO()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-r reqs-celery-5.txt
2+
-r reqs-django-5.0.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Django>=4.2,<5.0
2+
jinja2<4
3+
-r reqs-base.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Django>=5.0,<5.1
2+
jinja2<4
3+
-r reqs-base.txt

0 commit comments

Comments
 (0)